Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android apk Debug mode works fine but release mode gives too many warnings

I'm trying to get a signed APK from eclipse. I have a debuggable apk version that works fine. Now for release when I tried to compile and sign with Eclipse ADT, I get many warnings, most of which is can't find superclass or interface some.package.Class. So, I referred to this, this and many others unfortunately I couldn't reach anywhere!

I also get Note: there were 314 duplicate class definitions. warning

My progaurd-project.txt was untouched earlier. So, I added -libraryjars /libs/lib-name for each of the jars present at /EcliseProject/libs/ folder. So I came up with the following:

-libraryjars /libs/android-support-v4.jar -libraryjars /libs/apache-mime4j-core-0.7.2.jar -libraryjars /libs/gcm.jar -libraryjars /libs/httpclient-4.3.3.jar -libraryjars /libs/httpcore-4.3.2.jar -libraryjars /libs/httpmime-4.3.3.jar -libraryjars /libs/library.jar -libraryjars /libs/nineoldandroids-2.4.0.jar

By the end of this I got some 1800+ warnings most of them being not finding superclass or interface as mentioned above. So, I got the jars that have those classes and put them too in /lib/ folder and added -libraryjars entries including rt.jar, etc. Then I got even more warnings some of them saying library class org.xmlpull.v1.XmlPullParser depends on program class java.lang.String.

I tried adding -dontskipnonpubliclibraryclasses, adding some -dontwarn, etc. Nothing worked so far.

At some point I kept sufficient -dontwarnso that apk was made but it just brought up the login screen (1st activity) and once clicked on a button got stuck there.

I'm missing something very basic I guess. All these days I was testing with debug mode apk which works normally. Why is this trouble? Please help!!

like image 332
ranjjose Avatar asked Nov 11 '22 05:11

ranjjose


1 Answers

OK after a lot of googling and searching within stackoverflow itself, I have manages to get a solution. The following is my proguard-project.txt file:

-libraryjars /libs/android-support-v4.jar
-libraryjars /libs/apache-mime4j-core-0.7.2.jar
-libraryjars /libs/gcm.jar
-libraryjars /libs/httpclient-4.3.3.jar
-libraryjars /libs/httpcore-4.3.2.jar
-libraryjars /libs/httpmime-4.3.3.jar
-libraryjars /libs/library.jar
-libraryjars /libs/nineoldandroids-2.4.0.jar

-keepnames class org.apache.** {*;}
-keep public class org.apache.** {*;}
-dontwarn org.apache.commons.**
-dontwarn org.apache.http.annotation.ThreadSafe
-dontwarn org.apache.http.annotation.Immutable
-dontwarn org.apache.http.annotation.NotThreadSafe
-dontwarn org.apache.http.impl.auth.GGSSchemeBase
-dontwarn org.apache.http.impl.auth.KerberosScheme
-dontwarn org.apache.http.impl.auth.NegotiateScheme
-dontwarn org.apache.http.impl.auth.KerberosScheme
-dontwarn org.apache.http.impl.auth.SPNegoScheme
-dontwarn se.emilsjolander.stickylistheaders.StickyListHeadersListView
-dontwarn android.net.http.AndroidHttpClient

Hope it helps others, Thanks!

like image 179
ranjjose Avatar answered Nov 15 '22 05:11

ranjjose