在我的库中,我在release构建类型中使用consumerProguardFiles
。我的 proguard 角色是:
-obfuscationdictionary proguard-dictionary.txt
-classobfuscationdictionary proguard-dictionary.txt
-packageobfuscationdictionary proguard-dictionary.txt
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
-dump class_files.txt
-printseeds seeds.txt
-printusage unused.txt
-printmapping mapping.txt
-optimizations !code/simplification/arithmetic,!field/removal/writeonly,!field/marking/private,!class/merging/*,!code/allocation/variable
-flattenpackagehierarchy
-allowaccessmodification
-renamesourcefileattribute SourceFile
-keepattributes *Annotation*
-keepattributes Signature,MethodParameters,LocalVariableTable,LocalVariableTypeTable
-keepattributes SourceFile,LineNumberTable
-keepattributes Exceptions,InnerClasses
当开发人员在项目中使用我的库(AAR)并获取发布版本并使用 minifyEnabled true
时,找不到 proguard-dictionary.txt
:
AGPBI: {"kind":"error","text":"File not found: /Users/USER/.gradle/caches/transforms-2/files-2.1/12e928515abf78e8a4387fd92c3a399b/proguard-dictionary.txt","sources":[{"file":"/Users/USER
/.gradle/caches/transforms-2/files-2.1/12e928515abf78e8a4387fd92c3a399b/proguard-dictionary.txt"}],"tool":"D8"}
AGPBI: {"kind":"error","text":"File not found: /Users/USER
/.gradle/caches/transforms-2/files-2.1/12e928515abf78e8a4387fd92c3a399b/proguard-dictionary.txt","sources":[{"file":"/Users/USER
/.gradle/caches/transforms-2/files-2.1/12e928515abf78e8a4387fd92c3a399b/proguard-dictionary.txt"}],"tool":"D8"}
AGPBI: {"kind":"error","text":"File not found: /Users/USER
/.gradle/caches/transforms-2/files-2.1/12e928515abf78e8a4387fd92c3a399b/proguard-dictionary.txt","sources":[{"file":"/Users/USER
/.gradle/caches/transforms-2/files-2.1/12e928515abf78e8a4387fd92c3a399b/proguard-dictionary.txt"}],"tool":"D8"}
如何在不使用字典文件的情况下使用-obfuscationdictionary
?
或者
我该如何解决这个问题?
最佳答案
提到的所有规则都不应该进入由 consumerProguardFiles
指向的文件,它们看起来应该进入 proguardFiles
的行规则 build 图书馆。另外,除非您有非常特殊的要求,否则请从 proguardFiles
中删除所有 -obfuscationdictionary
、-classobfuscationdictionary
和 -packageobfuscationdictionary
> 建立图书馆将是最好的事情。
consumerProguardFiles
用于库的使用者需要拥有库才能工作的规则。所有这些规则都将进入使用该库的项目的构建中。如果您的库不使用反射,那么很可能根本不需要 consumerProguardFiles
。
关于android - 在我的 AAR 库中使用 ConsumerProguardFiles 并在使用混淆字典时获取未找到的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56621558/