This will be a short post. So, I have working with the Google API java library for Android and time has come to package the app for release and boom! ProGuard problems! First I had an issue with MinMaxPriorityQueue. When I tried to “Export Signed Application Package”, ProGuard would fail with a warning about this class. To get past this, you need to tell ProGuard not to warn you about it. Add this to your proguard.cfg:
-dontwarn com.google.common.collect.MinMaxPriorityQueue
Next, I had a problem with the JSON response from the API. It would complain about how there isn’t a publicly available constructor in a package (ex: com.google.api.a.a.a.d or something like that). Your error may not be the same but it is more or less the same problem as mine (or anyone else using Google API libraries for Android). So you need to tell ProGuard to keep certain API classes from obfuscation:
-keep class com.google.api<full package name of whatever library you are using>
I suggest also adding any other package (or individual classes) that you have declared in your application that is designated as a model for API responses. One last thing to note is, if your ProGuard config file doesn’t already have it, you should also add this:
-keepclassmembers class * {
@com.google.api.client.util.Key <fields>;
}
This would have already been added for you if you used the “android update project -p <your project>” in your command line (or Terminal) or if you have been using the latest Android tools.
I have added the -keepclassmembers class * {
@com.google.api.client.util.Key ;
}
but still not working when i change the location in my application.
LikeLike
See my replies below..
LikeLike
Can you email me the errors? Your statement is too generic for me to tell you what might be wrong with your proguard setup. Actually stating what errors you receive will help me help you.
LikeLike
Or at least paste the errors at pastebin.com and create a shareable url. Please don’t paste the stacktrace here.
LikeLike
i have posted there. please check it, revert me with solution
LikeLike
http://pastebin.com/kkbcadC0
LikeLike
Paste your full proguard config, the actual error stack trace. That way I can see what is wrong and what is missing in your proguard config to recommend adding something to it.
LikeLike
http://pastebin.com/fQHV2W0q
LikeLike
And what exactly is the problem? Do you see an exception in the logcat or do you run into problems while exporting a release build?
LikeLike
No i haven’t found any exception or problem while exporting a release build.did u find problem in the code ?.which i sent to u.
LikeLike
I can’t tell unless you tell me what problem it is that you have? I don’t have your full project so I can’t run code and find out what the problem is.
LikeLike
It is not creating places object in the model package
LikeLike
it is showing “Caused by: java.lang.InstantiationException:” com.ideafarms.android.dealchaat.models.Place$Geometry
LikeLike
http://pastebin.com/KkxmZPzd
LikeLike
Sorry for the late response but add this to your proguard config: -keep public class com.ideafarms.android.dealchaat.models.**
LikeLike
thx
LikeLike