Android This feature requires ASM7

Viewed 1511

Possible duplicate

I have updated my Android Studio to

'Android Studio Arctic Fox | 2020.3.1 Patch 3'

Java is updated from jdk 1.8 to jdk 11

compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }


kotlinOptions {
        jvmTarget = '11'
    }

I have also upgraded gradle to

'com.android.tools.build:gradle:7.0.3'

Here is my full gradle build file

Gradle (Module)

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-android-extensions'
    id 'androidx.navigation.safeargs.kotlin'
    id 'kotlin-kapt'
    id 'io.michaelrocks.paranoid'
    id 'com.google.gms.google-services'
    id 'com.google.firebase.crashlytics'
}

android {

    compileSdk 32

    defaultConfig {
        applicationId "com.company.project"
        minSdk 21
        targetSdk 32
        versionCode 13
        versionName "2.0.34"
        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        externalNativeBuild {
            cmake {
                cppFlags ""
                //cppFlags "-pie -fPIE"
            }
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    testOptions {
        unitTests {
            includeAndroidResources = true
            returnDefaultValues = true
        }
    }
    packagingOptions {
        exclude 'META-INF/AL2.0'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/atomicfu.kotlin_module'
    }
    kotlinOptions {
        jvmTarget = '11'
    }
    dataBinding {
        enabled = true
    }
    externalNativeBuild {
        cmake {
            path "src/main/jni/CMakeLists.txt"
            version "3.10.2"
        }
    }
    ndkVersion '21.0.6113669'

    signingConfigs {
        debug {
            // Signing configs
            storeFile file("../keystore/debug.keystore")
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
        release {
            // Signing configs
            storeFile file("../keystore/release.keystore")
            storePassword 'company1234'
            keyAlias 'company_key'
            keyPassword 'company1234'
            enableV2Signing = true
            enableV3Signing = true
            enableV4Signing = true
        }
    }

    buildTypes {
        debug {
            signingConfig signingConfigs.debug
            minifyEnabled false
            applicationVariants.all {
                variant - >
                    renameAPK(variant, applicationName, defaultConfig, 'D')
            }
        }
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            applicationVariants.all {
                variant - >
                    renameAPK(variant, applicationName, defaultConfig, 'R')
            }
            ndk {
                abiFilters "armeabi-v7a", "arm64-v8a", "x86"
            }
        }
    }

    flavorDimensions "ht"
    productFlavors {
        dev {
            applicationId "com.company.project"
            buildConfigField "int", "FlavorCode", "1"
        }
        staging {
            applicationId "com.company.project"
            buildConfigField "int", "FlavorCode", "2"
        }
        prod {
            applicationId "com.company.project"
            buildConfigField "int", "FlavorCode", "3"
        }
    }
}

static def renameAPK(variant, applicationName, defaultConfig, buildType) {
    variant.outputs.each {
        output - >
            def formattedDate = new Date().format('dd-MM-yyyy_HH_mm')
        def fileName = applicationName + "_V" + defaultConfig.versionName + "_" + formattedDate + "_" + variant.flavorName + "_" + buildType + ".apk"
        output.outputFileName = new File(fileName)
    }
}

dependencies {

    /////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////
    ////////////////////////// Testing frameworks //////////////////////////
    /////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////

    //Testing frameworks
    testImplementation 'junit:junit:4.13.2'
    testImplementation 'androidx.test:core:1.4.0'
    testImplementation 'androidx.arch.core:core-testing:2.1.0'
    testImplementation 'org.mockito:mockito-core:3.5.13'
    testImplementation 'org.robolectric:robolectric:4.4'
    testImplementation 'org.robolectric:shadows-multidex:4.4'
    testImplementation "io.mockk:mockk:1.10.2"
    testImplementation 'io.mockk:mockk-common:1.10.2'
    testImplementation 'com.google.truth:truth:1.1.3'
    testImplementation 'org.apache.maven:maven-ant-tasks:2.1.3'

    // Android Tests
    androidTestImplementation "androidx.navigation:navigation-testing:$rootProject.ext.navigation"
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test:rules:1.4.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation 'androidx.test:runner:1.4.0'
    androidTestImplementation 'androidx.arch.core:core-testing:2.1.0'
    androidTestImplementation "androidx.test:core:1.4.0"

    androidTestImplementation "androidx.fragment:fragment-testing:$rootProject.ext.fragment_version"


    /////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////
    ////////////////////////// Normal Frameworks //////////////////////////
    /////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////

    // Multidex
    implementation 'com.android.support:multidex:1.0.3'

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.annotation:annotation:1.3.0'
    implementation "androidx.navigation:navigation-fragment-ktx:$rootProject.ext.navigation"
    implementation "androidx.navigation:navigation-ui-ktx:$rootProject.ext.navigation"
    implementation "androidx.navigation:navigation-runtime-ktx:$rootProject.ext.navigation"
    implementation "androidx.fragment:fragment-ktx:1.2.5"


    // Kotlin & JetBrains
    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.4.3'
    implementation 'com.github.florent37:inline-activity-result-kotlin:1.0.4'
    implementation 'org.jetbrains.anko:anko-appcompat-v7-commons:0.10.2'

    //Androidx UI Components
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation "androidx.cardview:cardview:1.0.0"

    // ViewModel LifeCycle
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'

    //Koin
    implementation "org.koin:koin-core:$rootProject.ext.koin_version"
    implementation "org.koin:koin-android:$rootProject.ext.koin_version"
    implementation "org.koin:koin-android-viewmodel:$rootProject.ext.koin_version"
    implementation "org.koin:koin-android-architecture:$rootProject.ext.koin_architecture_version"

    //ok http
    implementation "com.squareup.okhttp3:okhttp:4.9.0"
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    //Retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.7.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.google.code.gson:gson:2.8.8'

    // Room components
    implementation 'androidx.room:room-runtime:2.4.1'
    implementation 'androidx.room:room-ktx:2.4.1'
    kapt 'androidx.room:room-compiler:2.4.1'
    androidTestImplementation 'androidx.room:room-testing:2.4.1'

    // Navigation component
    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
    implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'

    // Import the BoM for the Firebase platform
    implementation platform('com.google.firebase:firebase-bom:28.4.0')

    // Firebase library dependencies
    implementation 'com.google.firebase:firebase-messaging'
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation 'com.google.firebase:firebase-crashlytics-ktx'
    implementation 'com.google.firebase:firebase-dynamic-links-ktx'

    // sdp and ssp for dp and sp values
    implementation 'com.intuit.sdp:sdp-android:1.0.6'
    implementation 'com.intuit.ssp:ssp-android:1.0.6'

    //permissions helper
    implementation 'com.karumi:dexter:6.2.0'

    //Facebook text encryption
    implementation 'com.facebook.conceal:conceal:2.0.1@aar'

    //Lottie animations
    implementation 'com.airbnb.android:lottie:3.4.2'

    // Location services
    implementation 'com.google.android.gms:play-services-location:19.0.1'

    implementation 'com.tbuonomo:dotsindicator:4.2'

    implementation 'com.github.bumptech.glide:glide:4.11.0'
    kapt 'com.github.bumptech.glide:compiler:4.11.0'
    implementation 'com.github.bumptech.glide:okhttp3-integration:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
    implementation 'com.github.bumptech.glide:annotations:4.11.0'

    implementation "org.ow2.asm:asm:7.0"
}

Gradle (Root/App)

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext{
        koin_version = '2.0.1'
        koin_architecture_version = "0.8.2"
        navigation = "2.3.5"
        fragment_version = "1.4.0"
    }
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.3'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5'
        classpath 'io.michaelrocks:paranoid-gradle-plugin:0.3.2'
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
    }
}

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

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

After upgrade, build failed with following exception

Execution failed for task ':app:transformClassesWithParanoidForDevDebug'.
> com.android.build.api.transform.TransformException: java.lang.IllegalArgumentException: Unable to read a ClassMirror for com/data/model/response/ParsingHelper$CharSequenceDeserializer

This feature requires ASM7

I have tried to fix specifically ParsingHelper class and updated its code to kotlin but then I get the same exception in different classes. So I believe fixing every java class in whole project is not a good idea.

As per this thread updating to AGP version 7.0.1 fixes the problem but I am already on a newer version which is 7.0.3.

3 Answers

You can give it a try by adding maven { url 'https://jitpack.io' }

to Settings.gradle

like this code:

Settings.Gradle

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
    google()
    mavenCentral()
    maven { url 'https://www.jitpack.io' } //here you can add this
    jcenter() // Warning: this repository is going to shut down soon
}
}
rootProject.name = "YourAppName"
include ':app'

and in build.gradle (Module) add this :

implementation 'org.ow2.asm:asm:7.0'

and build your project again.

for me currently the only thing helping is by rebuilding the project each time and then running the app.

Add to gradle files the following, clean the project and build again:

implementation "org.ow2.asm:asm:7.0"

Related