There are a few questions around but no solution that works for me. I thought it was suppose to be easy to use.
I just get a console full of can\'t find referenced cla
In my case Android Studio froze while doing ProGuard on release build. I killed it. And after the restart I started to see "can't find referenced class" warnings.
solution: I closed Android Studio, deleted .gradle folder from my project folder, then deleted gradle global cache (%USER_HOME%.gradle/caches). After reopening the project, caches was rebuild and everything started to work again.
If you have an error such as:
Warning: com.package...: can't find referenced class com.secondpackage....Classname
Just add to your file proguard-android.txt:
#if it is class:
-keep class com.package.*{ *; }
#or if it is interface:
-keep interface com.package.*{ *; }
#or if it is a class that extends from any other
-keep class * extends com.example.Model
#or if you know only and of className
-keep class **Starter { *; }
#or if you want to keep only fields of classes
-keepclassmembers class com.package.** {
*;
}
Also if you dont want to see all of notes in log use:
-dontnote com.package.**
This file name is written in build Gradle
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-android.txt'
}
}
Or if you want to add many files for example use the following repo And for add all of files:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
proguardFiles fileTree(include: ['*.pro'], dir: '../libraries').asList().toArray()
}
libraries
folder should be at D:\workspace\MyProject\libraries
Add to your config:
-libraryjars org.apache.jar // name of your jars.
-libraryjars org.w3c.jar
If it does not help add:
-dontwarn org.apache.** tag
or just ignore warnings (highly unrecommended since it could cause your app to crash at runtime over unsatisfied dependencies):
-ignorewarnings
This doc will help you : http://proguard.sourceforge.net/manual/troubleshooting.html
If you are using library projects, than you should add -libraryjars to your library proguard config
From what I can remember, it means you have referenced the Jar files in the wrong way.
Also, if your username (ME) contains spaces C:/Users/ME/android-sdks/tools/proguard/proguard-android.txt:proguard-project.txt
Proguard will break in "funny" ways. Move android-sdk to C:\android-sdk
and save yourself headache.