Android项目:proguard混淆之常见问题及解决方法汇总-创新互联
1.使用proguardgui混淆器对jar包进行混淆,出现EXCEPTION FROM SIMULATION错误:
公司主营业务:成都做网站、网站设计、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。成都创新互联公司是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。成都创新互联公司推出察哈尔右翼中旗免费做网站回馈大家。[2014-07-08 14:29:55 - Test024_HouseBox_v02_jar] Dx EXCEPTION FROM SIMULATION: [2014-07-08 14:29:55 - Test024_HouseBox_v02_jar] Dx local variable type mismatch: attempt to set or access a value of type java.lang.Object using a local variable of type int. This is symptomatic of .class transformation tools that ignore local variable information. [2014-07-08 14:29:55 - Test024_HouseBox_v02_jar] Dx ...at bytecode offset 0000012f locals[0000]: Lcom/android/volley/toolbox/BasicNetwork; locals[0001]: Lcom/android/volley/Request; locals[0002]: J locals[0003]:locals[0004]: Lorg/apache/http/HttpResponse; locals[0005]: [B locals[0006]: Ljava/util/Map; locals[0007]: Ljava/io/IOException; locals[0008]: locals[0009]: locals[000a]: stack[0001]: N012bLcom/android/volley/NoConnectionError; stack[top0]: N012bLcom/android/volley/NoConnectionError; ...while working on block 012e ...while working on method performRequest:(Lcom/android/volley/Request;)Lcom/android/volley/NetworkResponse; ...while processing performRequest (Lcom/android/volley/Request;)Lcom/android/volley/NetworkResponse; ...while processing com/android/volley/toolbox/BasicNetwork.class [2014-07-08 14:29:55 - Test024_HouseBox_v02_jar] Dx 1 error; aborting [2014-07-08 14:29:55 - Test024_HouseBox_v02_jar] Conversion to Dalvik format failed with error 1
解决方法:在配置文件中去掉-keepattributes LocalVariable*Table这个配置项。
参考资料:Android项目:自构框架、SDK包或者jar文件库的混淆及常见问题解决方法
2.引用库正常,对库的代码打成jar包混淆后运行报错Unable to execute dex: Multiple dex files define:
Unable to execute dex: Multiple dex files define Lcom/glblong/socshare/R$anim
解决方法:项目引用了不同版本的jar包导致的,如果libs中的jar包版本都是一致的,那么问题可能出现在使用proguradgui时引入的jar包版本不一致导致的。也就是在混淆过程中,引入的jar包要与项目中使用的jar文件一致。
参考资料:Android项目:自构框架、SDK包或者jar文件库的混淆及常见问题解决方法
3.在你依赖的外部jar包已经混淆的情况下再进行混淆打包有可能出现以下情况:
Can't read [***\***.jar] (Can't process class [**/a/f.class] (Unknown verification type [108] in stack map frame))
[2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] Proguard returned with error code 1. See console [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] java.io.IOException: Can't read [F:\work_hb_v02_pbulish\Lib_SocShare_v237_0703\libs\untiy-classes.jar] (Can't process class [com/unity3d/player/UnityPlayer.class] (Unknown verification type [251] in stack map frame)) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.InputReader.readInput(InputReader.java:232) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.InputReader.readInput(InputReader.java:202) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.InputReader.readInput(InputReader.java:180) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.InputReader.execute(InputReader.java:78) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.ProGuard.readInput(ProGuard.java:196) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.ProGuard.execute(ProGuard.java:78) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.ProGuard.main(ProGuard.java:483) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] Caused by: java.io.IOException: Can't process class [com/unity3d/player/UnityPlayer.class] (Unknown verification type [251] in stack map frame) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.io.Cla***eader.read(Cla***eader.java:112) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.io.JarReader.read(JarReader.java:65) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.InputReader.readInput(InputReader.java:228) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] ... 6 more [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] Caused by: java.lang.RuntimeException: Unknown verification type [251] in stack map frame [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.classfile.io.ProgramCla***eader.createVerificationType(ProgramCla***eader.java:890) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.classfile.io.ProgramCla***eader.visitFullFrame(ProgramCla***eader.java:659) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.classfile.attribute.preverification.FullFrame.accept(FullFrame.java:114) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.classfile.io.ProgramCla***eader.visitStackMapTableAttribute(ProgramCla***eader.java:452) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.classfile.attribute.preverification.StackMapTableAttribute.accept(StackMapTableAttribute.java:71) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.classfile.io.ProgramCla***eader.visitCodeAttribute(ProgramCla***eader.java:422) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.classfile.attribute.CodeAttribute.accept(CodeAttribute.java:101) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.classfile.io.ProgramCla***eader.visitProgramMethod(ProgramCla***eader.java:200) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.classfile.io.ProgramCla***eader.visitProgramClass(ProgramCla***eader.java:142) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.classfile.ProgramClass.accept(ProgramClass.java:346) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.io.Cla***eader.read(Cla***eader.java:91) [2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] ... 12 more
解决方法:找到proguard源码中proguard\src\proguard\classfile\ClassConstants.java类,然后修改ATTR_StackMapTable的值,将原来的的StackMapTable改为dummy.
public static final String ATTR_StackMapTable = "dummy";//"StackMapTable";
然后重新ant打包proguard,使用新的proguard来混淆就不会出现上面的问题。
ant打包proguard方法见:Android项目:通过ant重新打包proguard混淆器jar文件
参考资料:
1.Proguard returned with error code 1. (Proguard errors with untiy-classes.jar)
2.ProGuard Java Optimizer and Obfuscator
3.Android项目:通过ant重新打包proguard混淆器jar文件
其他参考资料:
1.Android项目:proguard混淆之常见问题及解决方法汇总
2.Android项目:proguard混淆之常见开源项目混淆配置
3.Android项目:自构框架、SDK包或者jar文件库的混淆及常见问题解决方法
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网站标题:Android项目:proguard混淆之常见问题及解决方法汇总-创新互联
分享链接:http://hbruida.cn/article/diggph.html