Android Roboguice not working with Proguard

家住魔仙堡 提交于 2019-12-12 06:14:26

问题


this is my proguard-project.txt:

-keep class com.google.inject.** { *; }
-keep class javax.inject.** { *; }
-keep class javax.annotation.** { *; }
-keep class roboguice.** { *; }

-keepattributes Signature
-keepattributes *Annotation*
-keep class roboguice.**

-keep class com.google.inject.** { *; }


-keepclassmembers class * {
    @com.google.inject.Inject <fields>;
    @com.google.inject.Inject <init>(...);
}
-keep class javax.inject.** { *; }
-keep class javax.annotation.** { *; }


-keep class com.appmanager.ui.activities.** { *; }
-keep class com.appmanager.ui.fragments.** { *; }

I am getting 500 warnings: http://pastebin.com/HihG9c66

How is it possible to resolve this warnning and keep the code from crashing?


回答1:


The current (kept up-to-date) official list of ProGuard settings for RoboGuice is available at https://github.com/roboguice/roboguice/wiki/ProGuard

For me, the parts either not in that file or weren't default and I skipped originally, were:

-keep class com.mynamespace.MyRoboGuiceModule { *; }
-keep class com.mynamespace.SomeObjectThatGetsInjected { *; }
-dontobfuscate

I really didn't like removing obfuscation. But it makes it a lot easier to get ProGuard to work without going through every class one-by-one. (And it is one less step in mapping the stack traces from public crash reports.)

You can also add the following to the above to get it to compile, but it may still crash at runtime. So always test all codes paths in the compiled release build!

-dontwarn roboguice.**
-dontwarn org.roboguice.**


来源:https://stackoverflow.com/questions/29278951/android-roboguice-not-working-with-proguard

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