0

我一直在 Android Studio 中成功使用 DexGuard,Gradle没有任何问题。我最近尝试过OkBuck加快构建时间,这对我很有帮助。

虽然它能够为我构建调试和签名 APK,但是当我尝试使用 DexGuard 构建发布时,例如:

./buckw install --run app:bin_release

我收到以下错误:

Error: Unknown option '-dalvik' in line 9 of file 'SomeApp/app/build/okbuck/release/proguard.pro',
  included from line 60 of file 'buck-out/gen/app/bin_release/proguard/command-line.txt',
  included from argument number 1

BUILD FAILED: //app:bin_release failed with exit code 1:
proguard_obfuscation
stderr: Error: Unknown option '-dalvik' in line 9 of file 'SomeApp/app/build/okbuck/release/proguard.pro',
  included from line 60 of file 'buck-out/gen/app/bin_release/proguard/command-line.txt',
  included from argument number 1

提及 DexGuard 集成的细节可能是微不足道的,因为它是按照文档完成的,并且当我从 Android Studio 中构建或使用时工作正常./gradlew,但这里是:

SomeApp/build.gradle:

buildscript {
    ext {
        DEXGUARD_HOME = "$System.env.DEXGUARD_HOME"
    }

...    

SomeApp/app/build.gradle:

buildTypes {
    ...

    release {
         minifyEnabled true
         proguardFile DEXGUARD_HOME + "Dexguard-7.3.11/lib/dexguard-release-aggressive.pro"
         proguardFile 'dexguard-project.txt'
         signingConfig signingConfigs.release
     }
}
4

1 回答 1

2

该消息通常表明 ProGuard 仍处于启用状态 - ProGuard 不知道 DexGuard 选项-dalvik。您应该保留minifyEnabled设置为false. DexGuard 本身已经对所有代码和资源进行了缩减、优化和混淆处理。

于 2017-04-03T12:26:08.637 回答