Home > Blockchain >  Android gradle build failed with error No matching variant
Android gradle build failed with error No matching variant

Time:08-19

Facing this error while building the Android application

* What went wrong:
Execution failed for task ':app:mergeExtDexCiDebug'.
> Could not resolve all files for configuration ':app:ciDebugRuntimeClasspath'.
  > Failed to transform mypkg:mylib-1.0.0.aar (mypkg:mylib:1.0.0) to match attributes {
        artifactType=android-dex,
        asm-transformed-variant=NONE,
        dexing-enable-desugaring=true,
        dexing-is-debuggable=true,
        dexing-min-sdk=21,
        org.gradle.category=library,
        org.gradle.dependency.bundling=external,
        org.gradle.libraryelements=aar,
        org.gradle.status=integration,
        org.gradle.usage=java-runtime}.
      > Execution failed for DexingWithClasspathTransform: /Users/xxx/.gradle/caches/transforms-3/49baf52f7ba8b21fe69d66f95b8d5255/transformed/jetified-mylib-1.0.0-runtime.jar.
         > Error while dexing.

Using Gradle 7.5.1 and AGP version is 7.3.0-beta05 (tried earlier ones too). Android Studio version Android Studio Chipmunk | 2021.2.1 Patch 2.

As far as possible, I have verified I am using

compileOptions {
    sourceCompatibility JavaVersion.VERSION_11
    targetCompatibility JavaVersion.VERSION_11
}

kotlinOptions {
    jvmTarget = "11"
}

Still, it is complaining about Java 8 incompatibility. Any idea how I can find if any of the dependencies is using Java 8 and if that's even a problem?

CodePudding user response:

Looking into the logs (before this error is shown), I found another error message like

Compilation of classes ... requires its nest mates ... (unavailable) to be on program or class path.

Then it occurred that one of the SDKs I used cannot be upgraded to Java 11 and has to be Java 8. (I was trying to upgrade my current SDK as well as the dependent SDK to Java 11 and Gradle7). So downgrading just the Java version (11 back to 8) helped. Gradle/AGP version had no impact.

On a related note, this specific error message may be fixed in the upcoming Gradle release according to https://developer.android.com/studio/releases/fixed-bugs/studio/2021.3.1#android-studio-dolphin-canary-1-2021.3.1.1.

  • Related