使用 Proguard DX SimException 本地 0000 构建的 Android:无效
Posted
技术标签:
【中文标题】使用 Proguard DX SimException 本地 0000 构建的 Android:无效【英文标题】:Android build with Proguard DX SimException local 0000: invalid 【发布时间】:2011-09-03 19:14:57 【问题描述】:我正在使用 Ant > 1.8 + Proguard 4.6 构建我的 android 项目,但在构建过程中出现异常:
SimException:本地 0000:无效
请在下面找到所有构建日志:
Buildfile: build.xml
[setup] Android SDK Tools Revision 11
[setup] Project Target: Android 3.1
[setup] API level: 12
[setup] ------------------
[setup] Resolving library dependencies:
[setup] No library dependencies.
[setup] ------------------
[setup] WARNING: Attribute minSdkVersion in AndroidManifest.xml (4) is lower than the project target API level (12)
-set-release-mode:
-release-obfuscation-check:
-pre-build:
-dirs:
[echo] Creating output directories if needed...
-aidl:
[echo] Compiling aidl files into Java classes...
-renderscript:
[echo] Compiling RenderScript files into Java classes and RenderScript bytecode...
-resource-src:
[echo] Generating R.java / Manifest.java from the resources...
-pre-compile:
compile:
[javac] build.xml:459: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 3 source files to /bin/classes
-post-compile:
-obfuscate:
[delete] Deleting: /bin/proguard/original.jar
[delete] Deleting: /bin/proguard/obfuscated.jar
[jar] Building jar: /bin/proguard/original.jar
[proguard] ProGuard, version 4.6
[proguard] Reading input...
[proguard] Reading program jar [/bin/proguard/original.jar]
[proguard] Reading program jar [/libs/lJar.jar]
[proguard] Reading program jar [/libs/android-support-v4.jar]
[proguard] Reading program jar [libs/libGoogleAnalytics.jar]
[proguard] Reading library jar [/platforms/android-12/android.jar]
[proguard] Initializing...
[proguard] Note: the configuration refers to the unknown class 'com.android.vending.licensing.ILicensingService'
[proguard] Note: there were 1 references to unknown classes.
[proguard] You should check your configuration for typos.
[proguard] Ignoring unused library classes...
[proguard] Original number of library classes: 3012
[proguard] Final number of library classes: 656
[proguard] Printing kept classes, fields, and methods...
[proguard] Shrinking...
[proguard] Printing usage to [/bin/proguard/usage.txt]...
[proguard] Removing unused program classes and class elements...
[proguard] Original number of program classes: 401
[proguard] Final number of program classes: 312
[proguard] Inlining subroutines...
[proguard] Optimizing...
[proguard] Number of finalized classes: 183
[proguard] Number of vertically merged classes: 0 (disabled)
[proguard] Number of horizontally merged classes: 0 (disabled)
[proguard] Number of removed write-only fields: 0 (disabled)
[proguard] Number of privatized fields: 0 (disabled)
[proguard] Number of inlined constant fields: 631 (disabled)
[proguard] Number of privatized methods: 122
[proguard] Number of staticized methods: 63
[proguard] Number of finalized methods: 1089
[proguard] Number of removed method parameters: 78
[proguard] Number of inlined constant parameters: 29
[proguard] Number of inlined constant return values: 6
[proguard] Number of inlined short method calls: 48
[proguard] Number of inlined unique method calls: 147
[proguard] Number of inlined tail recursion calls: 3
[proguard] Number of merged code blocks: 11
[proguard] Number of variable peephole optimizations: 860
[proguard] Number of arithmetic peephole optimizations: 0 (disabled)
[proguard] Number of cast peephole optimizations: 186
[proguard] Number of field peephole optimizations: 1
[proguard] Number of branch peephole optimizations: 311
[proguard] Number of simplified instructions: 99
[proguard] Number of removed instructions: 2474
[proguard] Number of removed local variables: 82
[proguard] Number of removed exception blocks: 53
[proguard] Number of optimized local variable frames: 367
[proguard] Shrinking...
[proguard] Removing unused program classes and class elements...
[proguard] Original number of program classes: 312
[proguard] Final number of program classes: 297
[proguard] Optimizing...
[proguard] Number of finalized classes: 0
[proguard] Number of vertically merged classes: 0 (disabled)
[proguard] Number of horizontally merged classes: 0 (disabled)
[proguard] Number of removed write-only fields: 0 (disabled)
[proguard] Number of privatized fields: 0 (disabled)
[proguard] Number of inlined constant fields: 631 (disabled)
[proguard] Number of privatized methods: 1
[proguard] Number of staticized methods: 1
[proguard] Number of finalized methods: 0
[proguard] Number of removed method parameters: 68
[proguard] Number of inlined constant parameters: 39
[proguard] Number of inlined constant return values: 13
[proguard] Number of inlined short method calls: 0
[proguard] Number of inlined unique method calls: 1
[proguard] Number of inlined tail recursion calls: 0
[proguard] Number of merged code blocks: 0
[proguard] Number of variable peephole optimizations: 35
[proguard] Number of arithmetic peephole optimizations: 0 (disabled)
[proguard] Number of cast peephole optimizations: 0
[proguard] Number of field peephole optimizations: 0
[proguard] Number of branch peephole optimizations: 17
[proguard] Number of simplified instructions: 44
[proguard] Number of removed instructions: 676
[proguard] Number of removed local variables: 17
[proguard] Number of removed exception blocks: 0
[proguard] Number of optimized local variable frames: 19
[proguard] Shrinking...
[proguard] Removing unused program classes and class elements...
[proguard] Original number of program classes: 297
[proguard] Final number of program classes: 297
[proguard] Optimizing...
[proguard] Number of finalized classes: 0
[proguard] Number of vertically merged classes: 0 (disabled)
[proguard] Number of horizontally merged classes: 0 (disabled)
[proguard] Number of removed write-only fields: 0 (disabled)
[proguard] Number of privatized fields: 0 (disabled)
[proguard] Number of inlined constant fields: 631 (disabled)
[proguard] Number of privatized methods: 0
[proguard] Number of staticized methods: 1
[proguard] Number of finalized methods: 0
[proguard] Number of removed method parameters: 14
[proguard] Number of inlined constant parameters: 10
[proguard] Number of inlined constant return values: 14
[proguard] Number of inlined short method calls: 0
[proguard] Number of inlined unique method calls: 0
[proguard] Number of inlined tail recursion calls: 0
[proguard] Number of merged code blocks: 0
[proguard] Number of variable peephole optimizations: 8
[proguard] Number of arithmetic peephole optimizations: 0 (disabled)
[proguard] Number of cast peephole optimizations: 0
[proguard] Number of field peephole optimizations: 0
[proguard] Number of branch peephole optimizations: 1
[proguard] Number of simplified instructions: 4
[proguard] Number of removed instructions: 33
[proguard] Number of removed local variables: 5
[proguard] Number of removed exception blocks: 0
[proguard] Number of optimized local variable frames: 0
[proguard] Shrinking...
[proguard] Removing unused program classes and class elements...
[proguard] Original number of program classes: 297
[proguard] Final number of program classes: 297
[proguard] Optimizing...
[proguard] Number of finalized classes: 0
[proguard] Number of vertically merged classes: 0 (disabled)
[proguard] Number of horizontally merged classes: 0 (disabled)
[proguard] Number of removed write-only fields: 0 (disabled)
[proguard] Number of privatized fields: 0 (disabled)
[proguard] Number of inlined constant fields: 631 (disabled)
[proguard] Number of privatized methods: 0
[proguard] Number of staticized methods: 0
[proguard] Number of finalized methods: 0
[proguard] Number of removed method parameters: 1
[proguard] Number of inlined constant parameters: 0
[proguard] Number of inlined constant return values: 14
[proguard] Number of inlined short method calls: 0
[proguard] Number of inlined unique method calls: 0
[proguard] Number of inlined tail recursion calls: 0
[proguard] Number of merged code blocks: 0
[proguard] Number of variable peephole optimizations: 3
[proguard] Number of arithmetic peephole optimizations: 0 (disabled)
[proguard] Number of cast peephole optimizations: 0
[proguard] Number of field peephole optimizations: 0
[proguard] Number of branch peephole optimizations: 0
[proguard] Number of simplified instructions: 0
[proguard] Number of removed instructions: 4
[proguard] Number of removed local variables: 0
[proguard] Number of removed exception blocks: 0
[proguard] Number of optimized local variable frames: 0
[proguard] Shrinking...
[proguard] Removing unused program classes and class elements...
[proguard] Original number of program classes: 297
[proguard] Final number of program classes: 297
[proguard] Optimizing...
[proguard] Number of finalized classes: 0
[proguard] Number of vertically merged classes: 0 (disabled)
[proguard] Number of horizontally merged classes: 0 (disabled)
[proguard] Number of removed write-only fields: 0 (disabled)
[proguard] Number of privatized fields: 0 (disabled)
[proguard] Number of inlined constant fields: 631 (disabled)
[proguard] Number of privatized methods: 0
[proguard] Number of staticized methods: 0
[proguard] Number of finalized methods: 0
[proguard] Number of removed method parameters: 0
[proguard] Number of inlined constant parameters: 0
[proguard] Number of inlined constant return values: 14
[proguard] Number of inlined short method calls: 0
[proguard] Number of inlined unique method calls: 0
[proguard] Number of inlined tail recursion calls: 0
[proguard] Number of merged code blocks: 0
[proguard] Number of variable peephole optimizations: 1
[proguard] Number of arithmetic peephole optimizations: 0 (disabled)
[proguard] Number of cast peephole optimizations: 0
[proguard] Number of field peephole optimizations: 0
[proguard] Number of branch peephole optimizations: 0
[proguard] Number of simplified instructions: 0
[proguard] Number of removed instructions: 0
[proguard] Number of removed local variables: 0
[proguard] Number of removed exception blocks: 0
[proguard] Number of optimized local variable frames: 0
[proguard] Shrinking...
[proguard] Removing unused program classes and class elements...
[proguard] Original number of program classes: 297
[proguard] Final number of program classes: 297
[proguard] Obfuscating...
[proguard] Printing mapping to [/bin/proguard/mapping.txt]...
[proguard] Preverifying...
[proguard] Writing output...
[proguard] Preparing output jar [/bin/proguard/obfuscated.jar]
[proguard] Copying resources from program jar [/bin/proguard/original.jar]
[proguard] Copying resources from program jar [/libs/CabJar.jar]
[proguard] Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [CabJar.jar:META-INF/MANIFEST.MF])
[proguard] Copying resources from program jar [/libs/android-support-v4.jar]
[proguard] Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [android-support-v4.jar:META-INF/MANIFEST.MF])
[proguard] Copying resources from program jar [/libs/libGoogleAnalytics.jar]
[proguard] Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [libGoogleAnalytics.jar:META-INF/MANIFEST.MF])
[proguard] Printing classes to [/bin/proguard/dump.txt]...
-dex:
[echo] Converting compiled files and external libraries into /bin/classes.dex...
[apply] UNEXPECTED TOP-LEVEL EXCEPTION:
[apply] com.android.dx.cf.code.SimException: local 0000: invalid
[apply] at com.android.dx.cf.code.OneLocalsArray.throwSimException(OneLocalsArray.java:244)
[apply] at com.android.dx.cf.code.OneLocalsArray.get(OneLocalsArray.java:156)
[apply] at com.android.dx.cf.code.BaseMachine.localArg(BaseMachine.java:207)
[apply] at com.android.dx.cf.code.Simulator$SimVisitor.visitLocal(Simulator.java:580)
[apply] at com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:384)
[apply] at com.android.dx.cf.code.Simulator.simulate(Simulator.java:99)
[apply] at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:684)
[apply] at com.android.dx.cf.code.Ropper.doit(Ropper.java:639)
[apply] at com.android.dx.cf.code.Ropper.convert(Ropper.java:252)
[apply] at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:252)
[apply] at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:131)
[apply] at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:85)
[apply] at com.android.dx.command.dexer.Main.processClass(Main.java:369)
[apply] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:346)
[apply] at com.android.dx.command.dexer.Main.access$400(Main.java:59)
[apply] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:294)
[apply] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
[apply] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:130)
[apply] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
[apply] at com.android.dx.command.dexer.Main.processOne(Main.java:313)
[apply] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:233)
[apply] at com.android.dx.command.dexer.Main.run(Main.java:185)
[apply] at com.android.dx.command.dexer.Main.main(Main.java:166)
[apply] at com.android.dx.command.Main.main(Main.java:90)
[apply] ...at bytecode offset 0000001a
[apply] locals[0000]: <invalid>
[apply] locals[0001]: [C
[apply] locals[0002]: Ljava/io/PrintWriter;
[apply] locals[0003]: Ljava/lang/Object;
[apply] locals[0004]: <invalid>
[apply] locals[0005]: <invalid>
[apply] locals[0006]: <invalid>
[apply] locals[0007]: J
[apply] locals[0008]: <invalid>
[apply] ...while working on block 0019
[apply] ...while working on method b:(JLjava/io/PrintWriter;)V
[apply] ...while processing b (JLjava/io/PrintWriter;)V
[apply] ...while processing android/support/v4/b/c.class
[apply] 1 error; aborting
构建失败 /build.xml:547:执行此行时发生以下错误: /build.xml:278:应用返回:1
感谢您的帮助
【问题讨论】:
【参考方案1】:我已删除该选项:
-optimizationpasses 5
在android sdk生成的proguard.cfg中
它有效。
我不知道这个选项到底在做什么。
【讨论】:
更新:我已经用最新的 Android SDK(API 级别 13)重新启用了这个选项,它又可以工作了! 这可能并不完全相关。您一定已经停止进行混淆或其他操作。 ***.com/questions/5701126/… 有真正的解决方案。【参考方案2】:我遇到了同样的问题,通过添加 !code/allocation/variable 解决了这个问题。请在此处查看 Eric Lafortune 的回答:Compile with Proguard gives SimException: "local variable type mismatch"
【讨论】:
Holy-macro - 这对我有用,同时保持 _optimizationpasses以上是关于使用 Proguard DX SimException 本地 0000 构建的 Android:无效的主要内容,如果未能解决你的问题,请参考以下文章
使用 AndroidX 时,proguard-android-optimize.txt 中的“@Keep 支持注释”规则是不是仍然适用?
Proguard - 也使用模块中的 proguard 文件