minifyReleaseWithR8 FAILED

更新adroidstudio版本后,使用Androidx 编译release版本 混淆时 报错如下:

解决办法:
project/gradle.properties 中添加:

android.enableR8=false

奇怪的是在Windows系统编译没有问题,在Linux系统上编译才有该问题。
gradlew.bat app:assembleRelease
Windows上编译正常。

Ubuntu系统上编译异常:(未开启 useAndroidX 和 enableJetifier 的项目也是编译正常的)
./gradlew app:assembleRelease
报错信息

**Task :app:minifyReleaseWithR8 FAILED**
FAILURE: Build failed with an exception.

./gradlew app:assembleRelease --stacktrace
报错信息

        Caused by: java.lang.ArrayIndexOutOfBoundsException
                at sun.reflect.GeneratedConstructorAccessor239.newInstance(Unknown Source)
                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
                at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:598)
                at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1005)
                ... 119 more
        Caused by: [CIRCULAR REFERENCE: java.lang.ArrayIndexOutOfBoundsException: 0]

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

工程配置情况

project/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
project/gradle.properties
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
kotlin.code.style=official
android.useAndroidX=true
android.enableJetifier=true

project/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.5.21"
    repositories {
        maven {url 'https://maven.aliyun.com/repository/central'}
        maven {url 'https://maven.aliyun.com/repository/jcenter'}
        maven {url 'https://maven.aliyun.com/repository/google'}
        mavenCentral()
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.3.4'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven {url 'https://maven.aliyun.com/repository/central'}
        maven {url 'https://maven.aliyun.com/repository/jcenter'}
        maven {url 'https://maven.aliyun.com/repository/google'}
        mavenCentral()
        google()
        jcenter()
    }

}

task clean(type: Delete) {
    delete rootProject.buildDir
}
posted @ 2022-03-12 22:04  xiaomodecnblogs  阅读(499)  评论(0编辑  收藏  举报