proguard中的否定符(感叹号)应该允许我继续使用,但是apache库:
-keep class !org.apache.**
根据这些答案。那是要走的路:
但是,它混淆了我APK中的所有类。
这是我的build.gradle的一部分(我有Android Studio 3.5.3)
compileSdkVersion 29
buildToolsVersion "29.0.2"
//...
buildTypes {
release {
minifyEnabled true
proguardFiles /*getDefaultProguardFile('proguard-android.txt'),*/ 'proguard-rules.pro'
// Enables resource shrinking, which is performed by the
// Android Gradle plugin.
shrinkResources false
}
}
dependencies {
//Utility libs
implementation 'org.apache.commons:commons-collections4:4.1'
implementation 'org.apache.commons:commons-lang3:3.4'
implementation group: 'commons-io', name: 'commons-io', version: '2.5'
}
我想知道是不是新的R8引起了这个问题,但是按照android.enabledR8=false
的建议设置T. Neidhart无效。
[将-printconfiguration
添加到我的proguard-rules.pro
文件后,我看到-keep
遵循许多-keep class !org.apache.**
规则
-printconfiguration
-keep class !org.apache.**
# Referenced at ***anonymized***\app\build\intermediates\merged_manifests\release\AndroidManifest.xml:180
-keep class android.support.v4.app.CoreComponentFactory { <init>(); }
# Referenced at ***anonymized***\app\build\intermediates\merged_manifests\release\AndroidManifest.xml:180
-keep class com.mycompany.MyApplication { <init>(); }
# Referenced at C:\Users\***anonymized***\.gradle\caches\transforms-2\files-2.1\7f5f0b3369d8fa8a72a20e2278ec0acc\appcompat-v7-28.0.0\res\layout\abc_action_menu_item_layout.xml:17
-keep class android.support.v7.view.menu.ActionMenuItemView { <init>(...); }
Ezekiel Baniaga建议的方法也不起作用。相反,它保留了包括apache软件包在内的所有内容:
proguard-rules.pro
-printconfiguration
-dontshrink
-dontoptimize
-dontobfuscate
-keep,allowshrinking,allowoptimization,allowobfuscation class org.apache.**
如果这不再起作用,则应向R8项目提交错误报告。
为了在此期间继续使用Proguard,您可以将其添加到gradle.properties文件中:
android.enableR8 = false