Proguard: cannot find reference class

There are a few questions, but there is no solution that works for me. I thought this should be easy to use. I just get a console filled with can't find referenced class

This is my proguard-project.txt

 -injars bin/classes -injars libs -outjars bin/classes-processed.jar -libraryjars C:/Users/ME/android-sdks/platforms/android-10/android.jar -dontpreverify -repackageclasses '' -allowaccessmodification -optimizations !code/simplification/arithmetic -keepattributes *Annotation* -keep public class * extends android.app.Activity -keep public class * extends android.app.Application -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep public class * extends android.view.View { public <init>(android.content.Context); public <init>(android.content.Context, android.util.AttributeSet); public <init>(android.content.Context, android.util.AttributeSet, int); public void set*(...); } -keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet); } -keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet, int); } -keepclassmembers class * extends android.content.Context { public void *(android.view.View); public void *(android.view.MenuItem); } -keepclassmembers class * implements android.os.Parcelable { static android.os.Parcelable$Creator CREATOR; } -keepclassmembers class **.R$* { public static <fields>; } 

and project.properties

 #Proguard enabled proguard.config=C:/Users/ME/android-sdks/tools/proguard/proguard-android.txt:proguard-project.txt 

Some classes with warnings:

 org.apache.avalon.framework.logger.Logger org.apache.log4j.Category org.apache.log4j.Priority org.apache.log4j.Logger ... javax.servlet.ServletContextListener javax.servlet.ServletContextEvent org.w3c.dom.html.HTMLAnchorElement org.w3c.dom.html.HTMLObjectElement org.w3c.dom.html.HTMLTableSectionElement org.w3c.dom.html.HTMLFrameSetElement ... org.w3c.dom.events.DocumentEvent org.w3c.dom.traversal.NodeFilter ... org.w3c.dom.ranges.Range org.w3c.dom.ranges.RangeException ... org.w3c.dom.html.HTMLDocument 
+5
java android eclipse proguard
source share
5 answers

Add to your configuration:

 -libraryjars org.apache.jar // name of your jars. -libraryjars org.w3c.jar 

If this does not help add:

 -dontwarn org.apache.** tag 

or just ignore warnings (highly discouraged, as this may cause your application to crash at runtime over unsatisfied dependencies):

 -ignorewarnings 

This document will help you: http://proguard.sourceforge.net/manual/troubleshooting.html

+9
source share

If you have a bug like:

 Warning: com.package...: can't find referenced class com.secondpackage....Classname 

Just add to the file proguard-android.txt

 -keep class com.package.*{ *; } -dontwarn com.package.** 

This file name is written in build gradle.

 buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-android.txt' } } 
+4
source share

From what I remember, it means that you specified the Jar files incorrectly.

Also, if your username (ME) contains spaces C:/Users/ME/android-sdks/tools/proguard/proguard-android.txt:proguard-project.txt Proguard will break into “funny” ways. Move android-sdk to C:\android-sdk and save the headache.

+1
source share

If you use library projects, you must add -libraryjars to your proguard config library configuration

0
source share

In my case, Android Studio froze during the execution of ProGuard in the release. I killed him. And after the reboot, I started to see the warning "I can not find the reference classes."

Solution: I closed Android Studio, deleted the .gradle folder from my project folder, and then deleted the gradle global cache (% USER_HOME% .gradle / caches). After reopening the project, the caches were rebuild and everything started working again.

0
source share

All Articles