I've spent last one and a half days banging my head against the table because i could not build a signed apk file with proguard, because it had some errors, similar to this:
- cant find superclass or interface org.apache...
- cant find referenced class org.apache...
While debug builds and apk generation works without proguard, enabling proguard produces this error.
What i understood from this:
- google removed apache library from android sdk 23. While the classes itself are still there, they were removed from some kind of index
- thats why in debug modes everything works, but with enabled proguard proguard obfuscates apache classes making them unusable by some other libraries those are referencing apache classes
- it also became clear that no additional jar files or dependencies are needed, because your debug modes works ok, just the correct settings for proguard are needed. (im talking about google's advice to add apache legacy library)
The problematic classes those i seen in error logs were:
- org.apache.http.*
- android.net.http.*
Also when i made a build my app crashed because of support library obfuscations (i could not open the preference activity, i checked stack trace from emulator and seen that support libraries tried to reference obfuscated classes/methods).
Summarising, everything was fixed and working on release apk with the next lines in my proguard-rules.pro file:
-keep class org.apache.http.** { *; } -dontwarn org.apache.http.** -keep class android.net.http.** { *; } -dontwarn android.net.http.** -keep class android.support.v7.** { *; } -keep class android.support.v4.** { *; }
This comment has been removed by the author.
ReplyDelete