简体   繁体   中英

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.

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.

copy this

 implementation 'com.android.tools.build:aapt2:4.1.0-6503028' 

in Gradle in the Android Studio after that click Sync Now after finished click run to try

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM