“Unknown Source” in release apk

青春壹個敷衍的年華 提交于 2019-12-24 05:32:31

问题


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 =)


回答1:


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 =)




回答2:


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?



来源:https://stackoverflow.com/questions/13158048/unknown-source-in-release-apk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!