Issue
In my library i use consumerProguardFiles
in release build type. My proguard role is :
-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
When developers use my library (AAR) in the project and getting release build and use minifyEnabled true
, get proguard-dictionary.txt
is not found:
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"}
How can I use -obfuscationdictionary
without using a dictionary file?
or
How can I fix this?
Solution
Use the following code:
buildTypes {
debug {
minifyEnabled false
debuggable true
}
release {
minifyEnabled true
debuggable false
// automatically add your proguard rules into your library user
consumerProguardFiles 'proguard-rules.pro'
proguardFiles 'proguard-rules-dic.pro', 'proguard-rules.pro'
}
}
Posted on behalf of the question asker
Answered By - Dharman
Answer Checked By - Senaida (JavaFixing Volunteer)