Make Proguard completely ignore package

早过忘川 提交于 2021-02-05 05:50:07

问题


Is it possible to have Proguard enabled but keep some classes completely untouched by Proguard? I have the following lines in my proguard config file:

-keep class com.heyzap.** { *; }

But as I can see classes inside Heyzap package are actually changed anyway after Proguard pass (they are different from what I originally had in Heyzap jar file).

I don't know what exactly Proguard do with Heyzap SDK but after this build process fails on converting jar file to dex format with error:

EXCEPTION FROM SIMULATION: com.android.dx.rop.cst.CstInterfaceMethodRef cannot be cast to com.android.dx.rop.cst.CstMethodRef

Also I have -dontoptimize option enabled in my config.

Heyzap recommends to use this line to keep their SDK untouched:

-libraryjars libs/heyzap-ads-sdk.jar 

But Android Studio fails to compile the project with this line added because heyzap-ads-sdk.jar is automatically added to -injars list (it throws 'The same input jar is specified twice.' error).


回答1:


To make ProGuard completely ignore a package you can use:

-keepclasseswithmembers class com.my.package.** {*;}

But, the error you're getting means something else, you should try to remove -libraryjars libs/heyzap-ads-sdk.jar from your ProGuard file, because this library is probably being added somewhere else like in your build.gradle file, probably by this line:

compile fileTree(dir: 'libs', include: ['*.jar'])


来源:https://stackoverflow.com/questions/31128266/make-proguard-completely-ignore-package

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