Could not resolve all files for configuration ':launcher:releaseRuntimeClasspath'.

Everytime I get this error upon build:
“Could not resolve all files for configuration ‘:launcher:releaseRuntimeClasspath’. See the Console for details.”

Unity 2021.3.37 and other versions of 2021. Target API Level 34.

Stacktrace:

Note: E:\proj\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
ERROR:: D8: com.android.tools.r8.kotlin.H

FAILURE: Build completed with 3 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':launcher:mergeExtDexRelease'.
> Could not resolve all files for configuration ':launcher:releaseRuntimeClasspath'.
   > Failed to transform play-services-measurement-api-21.5.1.aar (com.google.android.gms:play-services-measurement-api:21.5.1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-incremental-transform=true, dexing-is-debuggable=false, dexing-min-sdk=22, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for DexingWithClasspathTransform: C:\Users\user\.gradle\caches\transforms-2\files-2.1\0a90e66ff9319bf31d2d761c3485ef0c\jetified-play-services-measurement-api-21.5.1-runtime.jar.
         > Error while dexing.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':launcher:bundleReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2ProcessResourcesRunnable
   > AAPT2 aapt2-4.2.2-7147631-windows Daemon #0: Unexpected error during link, attempting to stop daemon.
     This should not happen under normal circumstances, please file an issue if it does.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

3: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':launcher:processReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
   > AAPT2 aapt2-4.2.2-7147631-windows Daemon #1: Unexpected error during link, attempting to stop daemon.
     This should not happen under normal circumstances, please file an issue if it does.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

* Get more help at https://help.gradle.org

BUILD FAILED in 20s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

UnityEditor.GenericMenu:CatchMenu (object,string[],int)

Builds successfully if the target API level is 33. So can’t build for level 34.
Also unity 2022 versions with target API level is 34 build successfully.

I tried to double check passwords for project keystore, check/uncheck preferences/External Tools, reimported all, force resolve Android libraries, relaunch unity, etc. nothing works.
Also I have custom Main Manifest, Main Gradle Template, Launcher Gradle Template, Base Gradle Template, Gradle Properties Template. No Minify selected. Multidex enabled.

How can I build for level 34 on unity 2021.3.37?

did you find a fix? having same problem

I am building now with unity 2022.3.x.
Tried to build with unity 2021.3.38 - build happens. In some version they added something to be sure the build for API 34 happens normally. You can check release notes.
If the issue still exist, try to update all the SDKs in your project. Also you can try to copy folders for Android SDK Tools, gradle, NDK, OpenJDK to another location (like C://…) and use that location for External tools.

Guys, do you know how to fix this error?

  • What went wrong:
    Execution failed for task ‘:launcher:checkReleaseAarMetadata’.

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
The minCompileSdk (34) specified in a
dependency’s AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module’s compileSdkVersion (android-33).
Dependency: androidx.media3:media3-extractor:1.2.1.
AAR metadata file: C:\Users\Администратор.gradle\caches\transforms-2\files-2.1\5b4b38751b389168237b92cbd884462f\jetified-media3-extractor-1.2.1\META-INF\com\android\build\gradle\aar-metadata.properties.

I just don’t know where I can change version to 33 for this thing, because if I change file mentioned in the error, it will change back while building and show me error again

This solution worked for me:

4 Likes

fixed by adding modfying and writing this number ==> “com.android.tools.build:gradle:4.2.0” in my “baseProjectTemplate”

here how it should be ===>


allprojects {
buildscript {
repositories {ARTIFACTORYREPOSITORY
google()
jcenter()
}
dependencies {
// If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity
// See which Gradle version is preinstalled with Unity here Unity - Manual: Gradle for Android
// See official Gradle and Android Gradle Plugin compatibility table here Android Gradle plugin 8.5 release notes  |  Android Studio  |  Android Developers
// To specify a custom Gradle version in Unity, go do “Preferences > External Tools”, uncheck “Gradle Installed with Unity (recommended)” and specify a path to a custom Gradle version
classpath ‘com.android.tools.build:gradle:4.2.0’
BUILD_SCRIPT_DEPS
}
}
repositories {ARTIFACTORYREPOSITORY
google()
jcenter()
flatDir {
dirs “${project(‘:unityLibrary’).projectDir}/libs”
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}


Thank you so much bro this solution worked for me

I tried this and I’m still getting this error in Unity 2022.3.52f1.
Any suggestions?

worked, thanks!!