Home » Android » gradle – Could not find com.android.tools.build:aapt2:3.3.2-5309881

gradle – Could not find com.android.tools.build:aapt2:3.3.2-5309881

Posted by: admin May 14, 2020 Leave a comment

Questions:

When I try to launch my app in Android Studio emulator
I get this error:

    Could not find com.android.tools.build:aapt2:3.3.2-5309881.
Searched in the following locations:
  - file:/C:/Users/jalal/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.3.2-5309881/aapt2-3.3.2-5309881.pom
  - file:/C:/Users/jalal/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.3.2-5309881/aapt2-3.3.2-5309881-windows.jar
  - file:/C:/Users/jalal/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.3.2-5309881/aapt2-3.3.2-5309881.pom
  - file:/C:/Users/jalal/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.3.2-5309881/aapt2-3.3.2-5309881-windows.jar
  - file:/C:/Users/jalal/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.3.2-5309881/aapt2-3.3.2-5309881.pom
  - file:/C:/Users/jalal/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.3.2-5309881/aapt2-3.3.2-5309881-windows.jar
  - https://jitpack.io/com/android/tools/build/aapt2/3.3.2-5309881/aapt2-3.3.2-5309881.pom
  - https://jitpack.io/com/android/tools/build/aapt2/3.3.2-5309881/aapt2-3.3.2-5309881-windows.jar
  - https://jcenter.bintray.com/com/android/tools/build/aapt2/3.3.2-5309881/aapt2-3.3.2-5309881.pom
  - https://jcenter.bintray.com/com/android/tools/build/aapt2/3.3.2-5309881/aapt2-3.3.2-5309881-windows.jar
Required by:
    project :app
How to&Answers:

add the google() in build.gradle

allprojects {
    repositories {
     google()  -->add this line 
     jcenter()   
    }

Answer:

I had to add the google() in two places to solve this

The path is <applicationName>\build.gradle. Note that there is another one which should not be confused with – <applicationName>\app\build.gradle.

1.

buildscript {
    repositories {
        jcenter()
        google()
    }
    ....
}

2.

allprojects {
    repositories {
        jcenter()
        google()
    }
}

Answer:

Hi, I solved this way.. in the project directory

android>build.gradle

classpath 'com.android.tools.build:gradle:3.0.1'

android>app>build.gradle

android {
    buildToolsVersion "28.0.3"
}