Android ProGuard obfuscation of library: keep class not working

我是研究僧i 提交于 2019-12-21 21:25:52

问题


Intro: I have in AS 1 project with 2 models:

  1. Android library project with some "Public API class"
  2. Android APP dependent on above library (the library module is on the dependency list)

Task: I want to obfuscate my library project because I want to expose it as public SDK but keep my code protected...

What I did: So I made custom ProGuard rules:

-dontshrink
-dontoptimize
-dontpreverify
-keep class com.org.my_public_api_class_name

I skip all other stages in order to eliminate where the bug is to only obfuscation stage.

Result: Build of the APP module fails with errors like

Error: cannot find symbol class my_public_api_class_name

It seems for me that the problem is that the obfuscation NOT skipped the class I wanted to, so now he has some meaningless name and therefore in the APP, where I'm using him, The original name not exist.

Thanks,


回答1:


To exclude your class from obfuscation, try this:

 -keep class com.org.my_public_api_class_name**
 -keepclassmembers class com.org.my_public_api_class_name** {*;}


来源:https://stackoverflow.com/questions/33648365/android-proguard-obfuscation-of-library-keep-class-not-working

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