proguard hell - can't find referenced class

AndroidProguard

Android Problem Overview


So, I'm TRYING to release some software but Proguard is giving me a headache.

When I try to export using proguard I'm getting lots of warning ie "can't find referenced class"

For example:

[2011-08-07 17:44:37 - GAME] Warning: org.simpleframework.xml.stream.StreamReader: can't find referenced class javax.xml.stream.events.XMLEvent
[2011-08-07 17:44:37 - GAME] Warning: there were 52 unresolved references to classes or interfaces.
[2011-08-07 17:44:37 - GAME]          You may need to specify additional library jars (using '-libraryjars'),
[2011-08-07 17:44:37 - GAME]          or perhaps the '-dontskipnonpubliclibraryclasses' option.
[2011-08-07 17:44:37 - GAME] java.io.IOException: Please correct the above warnings first.
[ 

The warnings seem to related to simpleframework, so in my proguard config file I've added the following:

-libraryjars pathtoprojecttolibs\simple-xml-2.4.jar

Where pathtoprojecttolibs is the path to jars which are referenced by my project.

This makes NO difference.

If simpleframework references javax can I tell proguard to ignore this too??

Any ideas?

Android Solutions


Solution 1 - Android

org.simpleframework.xml.stream.StreamReader in your code refers to javax.xml.stream.events.XMLEvent. The latter class is part of the Java runtime (rt.jar) but not part of the Android runtime (android.jar), so ProGuard warns that something might be broken. If you're sure that your application works anyway, you can specify

-dontwarn javax.xml.stream.events.**

ProGuard hell?

Solution 2 - Android

In my case the root cause was here. Those warnings you can just skip with :

-dontwarn org.simpleframework.xml.stream.**

The original answer is here

Solution 3 - Android

This error occurs because the libs you use depend on other libs which are not realy used, but Proguard is looking for them.
Add your -dontwarn lines to your proguard-rules.pro file in your Android project to disable this warnings.

enter image description here

You can find which dependencies you need to add to your proguard-rules.pro in the stacktrace of your error.

Solution 4 - Android

You should include this in your Proguard config:

-dontskipnonpubliclibraryclasses

Solution 5 - Android

My Magic key that solved my hours of searching: Add this to progruard-android.txt

-dontskipnonpubliclibraryclassmembers

Solution 6 - Android

Hmm. Reading that warning it would seem the library you are trying to use has a dependancy on javax.xml.stream.events. I don't think that namespace is actually included in android at all. (See Package Index).

Try deploying it to the emulator without using proguard and see if it works. My guess would be no if that warning is accurate.

Solution 7 - Android

I think this is an edge case but in my case I had to completely wipe the build folder on my Jenkins proguard tried to work with old code which was not there any more - just in case anybody has the same issue.

Solution 8 - Android

In my case I haven't changed anything and warning started to show. The problem was with broken gradle caches. Check my other answer. I share with this because it took my 2 hours to find the problem :]

Solution 9 - Android

Add this line to your proguard-rules.pro file in the gradle scripts directory:

-dontwarn package.class.name.**

where package.class.name is the package name with the class name of the jar file appended.

For example:

-dontwarn com.myexternalclass.utils.**

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioniasksillyquestionsView Question on Stackoverflow
Solution 1 - AndroidEric LafortuneView Answer on Stackoverflow
Solution 2 - AndroidYaroslav HavrylovychView Answer on Stackoverflow
Solution 3 - AndroidYuliia AshomokView Answer on Stackoverflow
Solution 4 - AndroidCrackerJack9View Answer on Stackoverflow
Solution 5 - AndroidAshraf AlshahawyView Answer on Stackoverflow
Solution 6 - AndroidalunView Answer on Stackoverflow
Solution 7 - AndroidluckyhandlerView Answer on Stackoverflow
Solution 8 - AndroidAppiDevoView Answer on Stackoverflow
Solution 9 - AndroidPedro MarthonView Answer on Stackoverflow