Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - Rebuild Project - Could not download aapt2-4.1.0-6503028-windows.jar

This is the configuration I have on my project:

  • Android Studio 4.1 (September 23, 2020)
  • Android Gradle Plugin Version 4.1.0
  • Gradle Version 6.7
  • Compile SDK 29 (Android 10.0 Q)
  • Build Tools 29.0.2
  • Min Sdk 17
  • Target Sdk 26 (Android 8.0 Oreo)

In the build.gradle of the project I have

buildscript {
    repositories {
        google()
        jcenter()
    }
}
....
allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

When I use the "Build> Rebuild Project" command in Build Output I get this error:

Execution failed for task ':app:mergeDebugResources'.
Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
Could not download aapt2-4.1.0-6503028-windows.jar (com.android.tools.build:aapt2:4.1.0-6503028): No cached version available for offline mode

Possible solution:
 - Disable offline mode and rerun the build
  • I tried with the "Toggle Offline Mode" in the Gradle panel (both to set it and to remove it), but the error still occurs.
  • I tried to clean the whole .gradle folder but same result.
  • I also created an emulator with API 30 because they suggested it would download the missing package, but it didn't change the situation.
  • I tried to manually download the jar (https://maven.google.com/web/index.html?q=aapt2#com.android.tools.build:aapt2:4.1.0-6503028) and put it in libs, but the error still comes out.
like image 706
asquo Avatar asked Nov 06 '20 20:11

asquo


1 Answers

A month too late for this, but I was also getting a similar error with not being able to download aapt2, but for a different version number.

Turns out, the order of the google() dependency mattered as mentioned here: https://developer.android.com/studio/releases/#aapt2_gmaven

So everywhere you are adding the dependency for google() move it up, and it should work for you as well.

like image 192
BurninatorDor Avatar answered Sep 26 '22 19:09

BurninatorDor