6

When I compiled my Android Studio IDE project, the emulator had opened, but project didn't run.I am using the latest version of Android IDE and I uninstalled Android IDE couple of times, and then again reinstalled it. Still, the problem persists.

Please help me fixing this problem.

When I run my Android Studio IDE project, I got this message at Build window:

Could not find com.android.tools.build:aapt2:3.3.1-5013011.
Searched in the following locations:
  - file:/C:/Users/zunayeed/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
  - file:/C:/Users/zunayeed/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
  - file:/C:/Users/zunayeed/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
  - file:/C:/Users/zunayeed/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
  - file:/C:/Users/zunayeed/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
  - file:/C:/Users/zunayeed/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
  - https://jcenter.bintray.com/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011.pom
  - https://jcenter.bintray.com/com/android/tools/build/aapt2/3.3.1-5013011/aapt2-3.3.1-5013011-windows.jar
Required by:
    project :app
shizhen
  • 12,251
  • 9
  • 52
  • 88
Zunayeed Kamal
  • 111
  • 2
  • 6
  • 1
    Possible duplicate of [Could not find com.android.tools.build:aapt2:3.2.0](https://stackoverflow.com/questions/50279792/could-not-find-com-android-tools-buildaapt23-2-0) – Gino Mempin Feb 12 '19 at 00:34
  • @GinoMempin's link provides a valid answer to your question. – shizhen Feb 12 '19 at 01:47
  • Possible duplicate of [Build errors after Android Studio 3.2.1 upgrade](https://stackoverflow.com/questions/52790020/build-errors-after-android-studio-3-2-1-upgrade) – Nikunj Paradva Apr 04 '19 at 04:34

2 Answers2

14

I think you missed google repository on your gradle file. To use AAPT2, make sure that you have a google() dependency in your build.gradle file, as shown here:

buildscript {
    repositories {
    google() // here
    jcenter()
}
dependencies {
   classpath 'com.android.tools.build:gradle:3.2.0-alpha12'

  }
} 
allprojects {
  repositories {
  google() // and here
  jcenter()
 }

Source: https://developer.android.com/studio/releases/#aapt2_gmaven

Farid Haq
  • 3,728
  • 1
  • 21
  • 15
  • Could you please be more specific ? I am new to this area. Where can I find build.gradle file ? I am still kind of confused. Thanks – Zunayeed Kamal Mar 07 '19 at 01:41
1

If you just had upgraded gradle build of your some old project, then you might try the following in your build.gradle file.

apply plugin: 'com.android.application'

repositories {
google()
jcenter()
} 
Irshad Babar
  • 1,311
  • 19
  • 26
  • 1
    I didn't upgrade. How can I upgrade the gradle of my android IDE ? – Zunayeed Kamal Mar 07 '19 at 01:42
  • If you have latest android studio, then it will ask you to upgrade gradle build through a pop-up, Further you can go through this post https://developer.android.com/studio/releases/gradle-plugin – Irshad Babar Mar 07 '19 at 12:20