本文介绍了“使用jack编译时无法测试混淆的变体"使用Jack工具链构建Android应用时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照本文 https://developer.android.com/preview/j8-jack.html ,但是一旦我添加

I'm trying to enable the Jack toolchain in my Android project by following the steps in this article https://developer.android.com/preview/j8-jack.html but as soon as I add

android {
    defaultConfig {
        jackOptions {
            enabled true
        }
    }
}

并运行gradle clean,我立即收到此错误:

and run gradle clean, I get this error right away:

我在一个非常简单的Android项目中进行了尝试,但仍然遇到相同的错误.这是一个示例gradle.build文件:

I tried it with a very simple Android project and I still get the same error. This is a sample gradle.build file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 7
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        jackOptions {
            enabled true
        }
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
}

推荐答案

D'哦!解决方法非常简单.显然,杰克与ProGuard和以下产品线不兼容:

D'oh! The fix was really simple. Apparently Jack is not compatible with ProGuard and the line:

release {
    minifyEnabled true
}

启用ProGuard,因为它现在称为"minify".将其切换为false可以解决此问题...我只是没有看到该行,因为它位于不同的部分...

enables ProGuard, since it's now called "minify". Switching it to false fixes the issue... I just didn't see the line because it was in a different section...

这篇关于“使用jack编译时无法测试混淆的变体"使用Jack工具链构建Android应用时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 16:19