Velja Radenkovic
Velja Radenkovic

Reputation: 716

java.lang.NoClassDefFoundError after proguard obfuscation

After exporting signed package from eclipse, application started crashing when one of activities is invoked.

05-30 23:05:43.814: E/AndroidRuntime(11578): FATAL EXCEPTION: main
05-30 23:05:43.814: E/AndroidRuntime(11578): java.lang.NoClassDefFoundError: com.encryptomatic.alockbin.ItemListActivity

I completely excluded that class from obfuscation with all members and I see it listed in seeds.txt .

Only difference from other activities is that this one extends SherlockFragmentActivity. I excluded dependencies altogether using:

-keep class android.support.v4.app.** { *; } 
-keep interface android.support.v4.app.** { *; } 
-keep class com.actionbarsherlock.** { *; } 
-keep interface com.actionbarsherlock.** { *; } 
-keepattributes *Annotation*

What could be wrong here? How can I check if my class really ended in apk?

Upvotes: 0

Views: 5944

Answers (2)

Robert
Robert

Reputation: 42710

The quick answer is: ProGuard was unable to detect that the class com.encryptomatic.alockbin.ItemListActivity is used by your code and therefore has removed it. This can happen if it is loaded dynamically or in a different unusual way.

Therefore if you use ProGuard you should simply add the mentioned class as class to "keep":

 -keep class com.encryptomatic.alockbin.ItemListActivity { public *; } 

Then re-build the APK and try it. Test all features of your app as most likely there are other classes that has to be configured to keep. If you have identified all classes also check the ProGuard warnings as they usually contain other classes that may be wise to keep.

Upvotes: 2

Velja Radenkovic
Velja Radenkovic

Reputation: 716

android-support-v4.jar was not set to export under Java Build Path in project properties:

Right click on Project -> Properties -> Java Build Path -> Order and export -> Check checkbox "Android private libraries" (the node where android-support-v4.jar resides on Library tab)

Upvotes: 0

Related Questions