Everything in my debug APK works just fine. However, when I export my APK and install it, everything works fine until I make a call to a referenced library.
E/AndroidRuntime(32571): at com.znood.znoodapp.ShowResultsActivity.a (Unknown Source)
I am using ProGuard.
My libraries are in the libs directory and are added to build path.
Any pointers are highly appreciated =)
The problem was with the Google Gson library. Proguard converts class names into obfuscated ones rendering json conversion buggy.
In order to solve this problem, make sure to have the following in your proguard-project.txt
# the classes that you use for Gson conversion
-keep class com.yourapp.objects.** { *; }
# without this line, I was having ClassCastException
-keepattributes Signature, *Annotation*
I hope this helps someone =)
If you haven't defined your libraries in proguard-project.txt then you can add like this
-libraryjars /libs/smack.jar
-libraryjars /libs/libphonenumber-5.0v1.5.jar
Android obfuscate app using proguard keeps obfuscating library jars - or is it?
Related
My app is able to run without any issues during testing etc. But when I export out apk compiled with ProGuard, there are issues like random crashing and some features not working as expected.
I not sure is it due to the external jar libraries I have included in the project which is not properly configured in Proguard.
I have included the following in the proguard-android.txt file. I have two libraries so I added these:
-keep class org.apache.commons.net.** { *; }
-keep class org.jsoup.** { *; }
Is it the correct way? Is there any other way?
To add libraries just add -libraryjars ../libs/<libname>
After that you may need to keep classes and interfaces based on the errors you receive
I have Android library project. There are some .aj files (aspectJ) with pointcuts.
I need to obfuscate compiled artifact (jar). When i obfuscate it and add as library to another project, aspects stops working.
Can anyone help with obfuscation using ProGuard? Some configuration examples or any useful information.
May be it is not possible at all? Are there some alternatives?
Thanks.
I also have an android library with aspects. My pointcuts are not for my library code, but for the app's code (pointcuts on Activity.onCreate, for example), so people who use my library are already expected to set up their android projects as AspectJ projects.
Everything works perfectly without Proguard, but despite making every exception I can think of I couldn't get the advice to apply if my library jar was obfuscated. I verified that the aspect class and all methods and fields were kept in the mapping.
Here's the final version of my proguard config that didn't get the aspects working, although everything compiles fine and there are no errors:
...some config, the injar included my iajc compiled library project with aspects
-optimizations !code/allocation/variable,!code/simplification/arithmetic,!field/*,!class/merging/*
-optimizationpasses 3
-dontpreverify
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-verbose
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
# This is the package of my aspects
-keep class my.package.aspectj.** { *; }
# This is all the public methods that my aspect code calls in to
-keep class my.package.allthethingsmyaspectscall.** { *; }
...keep some other classes not related to this
With all this my aspects still didn't apply.
My solution was to copy my aspect files into the client app's project at install time so that it is in their app classpath and gets woven when their app gets built.
a question on android proguard obfuscation.
For some reason, when generating apk using ant, I want proguard to shrink size (remove unused classes) but no name obfuscation. In proguard.cfg, I added:
-dontobfuscate
all others in proguard.cfg are either -dontwarn or -keep class. But after decompile the generated apk (dex2jar), I found many names are still obfuscated. Why this happens?
Thanks
Since nobody was actually answering this, here is the link to the post that solves the issue: Using Proguard with Android without obfuscation
Basically, what you need to add below your -dontobfuscate instruction is:
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/allocation/variable
Important thing here is: !code/allocation/variable
I recently signed an apk file for release on Google Play and when I downloaded the application on Google Play and installed it, it would throw java.lang.ExceptionInInitializerError.
My co-worker and I are suspecting that the library was not being added to our signed apk file.
We added our additional library to our project by adding it to our build path for the project.
Also, the library we are trying to add to our project is ActionBarSherlock.
Is there a reason why our library is not being included in our signed apk file, because we notice the file size for our signed apk is alot smaller than our unsigned version?
Can anyone point us in the right direction in signing our apk file correctly so that it includes the library we added into our build path?
I had the exact same error missing android.support.v4 jar file. deeJ is right if you look at ActionBarSherlock website it tells you to add the following in your proguard file:
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }
-keepattributes *Annotation*
I found out that the problem was Proguard not playing well with ActionBarSherlock. Try using tips given here:
http://actionbarsherlock.com/faq.html
Not sure on your exact build process, my suggestion would be to use Maven for your builds. It might be that your dependancies are only used on your debug build rather than your release build. Another thing I would suggest, before putting something on the app store use the Android Debug Bridge (adb) to manually install it on a device and check for these kinds of errors.
Did anyone have trouble with youtube api especially after running proguard?
My code to fetch videos from youtube worked just fine before running proguard, after running proguard i am getting strange exception
ERROR/AndroidRuntime(10197): Caused by: java.lang.IllegalArgumentException:
No parser defined for Content-Type: application/atom+xml; charset=UTF-8; type=feed
I'm not setting content type anywhere and i'm using the default proguard.cfg file that's generated while creating a new project.
Did anyone face similar issues after running proguard?
Tried proguard without obfuscating, without optimization but it gives the same result.
Not sure if google-api-client is exactly the same as the gdata you mention, but it must be very similar. Since Proguard will often break your code, you have to tell it what it can and cannot do. It's not by any means a miracle tool that understands reflection.
I had to add this among others:
-keepattributes *Annotation* # Needed by google-api-client
-keepattributes Signature # Needed by google-api-client
# Needed by google-api-client to keep generic types and #Key annotations accessed via reflection
-keepclassmembers class * {
#com.google.api.client.util.Key <fields>;
}
# Needed by Guava (google-api-client)
-dontwarn sun.misc.Unsafe