使Proguard完全忽略软件包 [英] Make Proguard completely ignore package

查看:75
本文介绍了使Proguard完全忽略软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以启用Proguard,但使某些类完全不受Proguard的影响?我的proguard配置文件中包含以下几行:

 -保留类com.heyzap.** {*;} 

但是,正如我看到的那样,在Proguard通过之后,Heyzap软件包中的类实际上还是被更改了(它们与我最初在Heyzap jar文件中所拥有的不同).

我不知道Proguard到底对Heyzap SDK做了什么,但是在此构建过程之后,无法将jar文件转换为dex格式并出现错误:

 模拟异常:com.android.dx.rop.cst.CstInterfaceMethodRef无法转换为com.android.dx.rop.cst.CstMethodRef 

我的配置中还启用了 -dontoptimize 选项.

Heyzap建议使用此行以保持其SDK不变:

  -libraryjars libs/heyzap-ads-sdk.jar 

但是Android Studio无法编译添加了此行的项目,因为 heyzap-ads-sdk.jar 被自动添加到 -injars 列表中(它抛出'同一个输入jar被指定两次.'错误).

解决方案

要使ProGuard完全忽略软件包,可以使用:

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

但是,您收到的错误意味着其他问题,您应该尝试从ProGuard文件中删除 -libraryjars libs/heyzap-ads-sdk.jar ,因为可能正在添加此库像您的 build.gradle 文件中的其他地方,可能是此行:

 编译fileTree(dir:'libs',包括:['* .jar']) 

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

解决方案

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'])

这篇关于使Proguard完全忽略软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆