本文共 6155 字,大约阅读时间需要 20 分钟。
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 0000012flocals[0000]: Lcom/android/volley/toolbox/BasicNetwork;locals[0001]: Lcom/android/volley/Request;locals[0002]: Jlocals[0003]:locals[0004]: Lorg/apache/http/HttpResponse;locals[0005]: [Blocals[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这个配置项。
参考资料:
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文件一致。
参考资料:
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.ClassReader.read(ClassReader.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.ProgramClassReader.createVerificationType(ProgramClassReader.java:890)[2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.classfile.io.ProgramClassReader.visitFullFrame(ProgramClassReader.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.ProgramClassReader.visitStackMapTableAttribute(ProgramClassReader.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.ProgramClassReader.visitCodeAttribute(ProgramClassReader.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.ProgramClassReader.visitProgramMethod(ProgramClassReader.java:200)[2014-07-17 10:51:15 - Test025_HouseBox_v02_test10] at proguard.classfile.io.ProgramClassReader.visitProgramClass(ProgramClassReader.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.ClassReader.read(ClassReader.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方法见:
参考资料:
1.
2.
3.