Failed to transform moshi-1.13.0.jar (failed for task biometric_storage:kaptGenerateStubsDebugKotlin)

1,508

NOTE: I am the one who asked this question. The following solutions are independent and you can try just one of them or you can combine them. Choose the one that looks simpler and if that works then there is no need for the other ones.

SOLUTION 1

Try ignoring that one .jar that is causing the problem. Use android.jetifier.blacklist or android.jetifier.ignorelist (LINK TO RELATED QUESTION) depending on the version of Android Gradle plugin version that you are using (to check which version you use, go to your build.gradle and check com.android.tools.build:gradle:X.Y.Z ). If you use anything before 7.0.0 use android.jetifier.blacklist and after use android.jetifier.ignorelist.

I use 3.6.0 so for me android.jetifier.blacklist works and android.jetifier.ignorelist does not.

SOLUTION 2

Try updating gradle and android gradle plugin to version 7. I did not try this and I can't because this isn't my personal project, but if you can go for it. Why I think upgrading will help? Well this github issue talks about that.

SOLUTION 3

The following solution doesn't make any sense (at least to me, if someone can explain why this fixes the problem please do), but for some strange reason it works.

I add a new library called bye-bye-jetifier because my idea was that I should turn off jetifier. Prior to turning it off I have to check if I have any dependence that uses outdated code (the code that is not AndroidX) hence I decided to install bye-byte-jetifier. After installing my build.gradle looked like this. After running with the following config the problem was gone.

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()   // <--------- I added this
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.0'
        classpath 'com.google.gms:google-services:4.3.5'
        classpath 'com.dipien:bye-bye-jetifier:1.2.1' // <--------- I added this
    }
}
allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

ext.kotlin_version = '1.4.31'

Note that I didn't even apply the plugin (like the offical guide on bye-bye-jetifier says), that makes this solution even more confusing.

Share:
1,508
Pero122
Author by

Pero122

Graduated from FER. Eager to become a full stack developer with focus in the backend.

Updated on January 03, 2023

Comments

  • Pero122
    Pero122 over 1 year

    I pulled a team's project that is made in Flutter from Git and for some reason when building the app (pressing the green arrow in Android Studio and running main.dart) I get the following message:

    What went wrong:
    Execution failed for task ':biometric_storage:kaptGenerateStubsDebugKotlin'.
    > Could not resolve all files for configuration ':biometric_storage:kapt'.
       > Failed to transform moshi-1.13.0.jar (com.squareup.moshi:moshi:1.13.0) to match attributes {artifactType=processed-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
          > Execution failed for JetifyTransform: C:\Users\UserName\.gradle\caches\modules-2\files-2.1\com.squareup.moshi\moshi\1.13.0\da685586facab9eb5c4fb630ce248be14e7da21b\moshi-1.13.0.jar.
             > Failed to transform 'C:\Users\UserName\.gradle\caches\modules-2\files-2.1\com.squareup.moshi\moshi\1.13.0\da685586facab9eb5c4fb630ce248be14e7da21b\moshi-1.13.0.jar' using Jetifier. Reason: Unsupported class file major version 60. (Run with --stacktrace for more details.)
    

    My build.gradle

    buildscript {
        repositories {
            google()
            jcenter()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:3.6.0'
            classpath 'com.google.gms:google-services:4.3.5'
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    
    rootProject.buildDir = '../build'
    subprojects {
        project.buildDir = "${rootProject.buildDir}/${project.name}"
    }
    subprojects {
        project.evaluationDependsOn(':app')
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
    ext.kotlin_version = '1.4.31'
    

    My gradle-wrapper.properties

    distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
    

    Other maybe relevant info

    Fluter Android Studio plugin 63.2.1
    Dart Android Studio plugin 203.8452
    Dart 2.15.1
    Flutter 2.8.1
    

    Nobody on my team gets this message so I suspect It has to do with some local configuration difference or maybe I have a different version of some program. Also, I can't update Gradle because that causes some other problems. EDIT: After clearing the cache all of my teammates, got this error.

  • Mike
    Mike about 2 years
    If I add to ignore list, I get java.lang.ClassNotFoundException com.squareup.moshi.w.b.a
  • DeniSHow
    DeniSHow almost 2 years
    android.jetifier.blacklist = com.squareup.moshi - worked for me.
  • Mirza Hayat
    Mirza Hayat almost 2 years
    android.jetifier.ignorelist=android-base-common,common,moshi‌​-1.13.0.jar. worked for me, by doing this keyboard not open,