方法签名的 Proguard 错误

发布于 2024-10-16 21:30:49 字数 3914 浏览 5 评论 0原文

我在尝试制作 Android 应用程序的 Proguard 版本时遇到奇怪的错误。错误是:

[proguard] Optimizing...  [proguard]
Unexpected error while evaluating
instruction:  [proguard]   Class      
= [net/domain/packagename/service/ExifEditor]
[proguard]   Method      =
[setGpsLocation(DDDJ)V]  [proguard]  
Instruction = [294] aload_3 v3 
[proguard]   Exception   =
[java.lang.IllegalArgumentException]
(Value is not a reference value
[proguard.evaluation.value.UnknownDoubleValue])
[proguard] Unexpected error while
performing partial evaluation: 
[proguard]   Class       =
[net/domain/packagename/service/ExifEditor]
[proguard]   Method      =
[setGpsLocation(DDDJ)V]  [proguard]  
Exception   =
[java.lang.IllegalArgumentException]
(Value is not a reference value
[proguard.evaluation.value.UnknownDoubleValue])

BUILD FAILED
D:\sdk\google\android-sdk-windows\tools\ant\main_rules.xml:430: java.lang.IllegalArgumentException:
Value is not a reference value
[proguard.evaluation.value.UnknownDoubleValue]
        at proguard.evaluation.value.Value.referenceValue(Value.java:97)
        at proguard.evaluation.Variables.aload(Variables.java:264)
        at proguard.evaluation.Processor.visitVariableInstruction(Processor.java:677)
        at proguard.classfile.instruction.VariableInstruction.accept(VariableInstruction.java:306)
        at proguard.optimize.evaluation.PartialEvaluator.evaluateSingleInstructionBlock(PartialEvaluator.java:729)
        at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlock(PartialEvaluator.java:560)
        at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlockAndExceptionHandlers(PartialEvaluator.java:533)
...and so on...

方法“setGpsLocation”具有以下签名:

public void setGpsLocation(double longitude, double latitude, double altitude, long gpsTime) throws IOException

我最终通过将方法更改为这样来摆脱错误:

public void setGpsLocation(Location location)

并且错误消失了。虽然这让我过去了,但我不明白第一个方法签名出了什么问题。我的 proguard.cfg 有 -optimizationpasses 2。如果我将此值增加到 3 或更多,我就会开始在其他代码区域看到类似的错误。如果我使用 3,会发生以下情况:

[proguard] Optimizing...   [proguard]
Unexpected error while evaluating
instruction:   [proguard]   Class     
= [org/apache/commons/fileupload/util/Streams]
[proguard]   Method      =
[copy(Ljava/io/InputStream;Ljava/io/OutputStream;Z[B)J]
[proguard]   Instruction = [75]
aload_2 v2   [proguard]   Exception  
= [java.lang.IllegalArgumentException] (Value is not a reference value
[proguard.evaluation.value.UnknownIntegerValue])
[proguard] Unexpected error while
performing partial evaluation: 
[proguard]   Class       =
[org/apache/commons/fileupload/util/Streams]
[proguard]   Method      =
[copy(Ljava/io/InputStream;Ljava/io/OutputStream;Z[B)J]
[proguard]   Exception   =
[java.lang.IllegalArgumentException]
(Value is not a reference value
[proguard.evaluation.value.UnknownIntegerValue])

我很难找到有关此错误含义的信息。

还有其他人见过类似的东西吗?

更新

虽然更改签名似乎可以解决问题,但我遇到了运行时崩溃:

I/dalvikvm(30523): Could not find method a.b.a.b.d.b, referenced from method a.b.a.b.d.a
W/dalvikvm(30523): VFY: unable to resolve direct method 440: La/b/a/b/d;.b (Ljava/lang/String;[BII)La/b/a/b/a;
D/dalvikvm(30523): VFY: replacing opcode 0x70 at 0x0039
D/dalvikvm(30523): VFY: dead code 0x003c-0041 in La/b/a/b/d;.a (Ljava/lang/String;[BII)[La/b/a/b/a;
W/dalvikvm(30523): VFY: 'this' arg 'Ljava/lang/Object;' not instance of 'Ljava/io/InputStream;'
W/dalvikvm(30523): VFY:  rejecting opcode 0x6e at 0x0045
W/dalvikvm(30523): VFY:  rejected La/b/a/a/a/b;.a (La/b/a/b/a/a;La/b/a/a;)La/b/a/a/a/c;
W/dalvikvm(30523): Verifier rejected class La/b/a/a/a/b;
W/dalvikvm(30523): threadid=10: thread exiting with uncaught exception (group=0x400259f8)

我开始阅读更多 Proguard 手册,发现通过添加 -dontoptimize,构建时错误和运行时崩溃消失了离开。这有点违背了使用 Proguard 的目的,不是吗?

-凯文

I'm getting a strange error while trying to make a Proguard version of my Android app. The error is:

[proguard] Optimizing...  [proguard]
Unexpected error while evaluating
instruction:  [proguard]   Class      
= [net/domain/packagename/service/ExifEditor]
[proguard]   Method      =
[setGpsLocation(DDDJ)V]  [proguard]  
Instruction = [294] aload_3 v3 
[proguard]   Exception   =
[java.lang.IllegalArgumentException]
(Value is not a reference value
[proguard.evaluation.value.UnknownDoubleValue])
[proguard] Unexpected error while
performing partial evaluation: 
[proguard]   Class       =
[net/domain/packagename/service/ExifEditor]
[proguard]   Method      =
[setGpsLocation(DDDJ)V]  [proguard]  
Exception   =
[java.lang.IllegalArgumentException]
(Value is not a reference value
[proguard.evaluation.value.UnknownDoubleValue])

BUILD FAILED
D:\sdk\google\android-sdk-windows\tools\ant\main_rules.xml:430: java.lang.IllegalArgumentException:
Value is not a reference value
[proguard.evaluation.value.UnknownDoubleValue]
        at proguard.evaluation.value.Value.referenceValue(Value.java:97)
        at proguard.evaluation.Variables.aload(Variables.java:264)
        at proguard.evaluation.Processor.visitVariableInstruction(Processor.java:677)
        at proguard.classfile.instruction.VariableInstruction.accept(VariableInstruction.java:306)
        at proguard.optimize.evaluation.PartialEvaluator.evaluateSingleInstructionBlock(PartialEvaluator.java:729)
        at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlock(PartialEvaluator.java:560)
        at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlockAndExceptionHandlers(PartialEvaluator.java:533)
...and so on...

The method "setGpsLocation" has this signature:

public void setGpsLocation(double longitude, double latitude, double altitude, long gpsTime) throws IOException

I ended up getting rid of the error, by changing the method to this:

public void setGpsLocation(Location location)

and the error goes away. While this gets me past it, I don't understand what was wrong with the first method signature. My proguard.cfg has -optimizationpasses 2. If I increase this value to 3 or more, I start seeing similar errors with other areas of code. Here's what happens if I use 3:

[proguard] Optimizing...   [proguard]
Unexpected error while evaluating
instruction:   [proguard]   Class     
= [org/apache/commons/fileupload/util/Streams]
[proguard]   Method      =
[copy(Ljava/io/InputStream;Ljava/io/OutputStream;Z[B)J]
[proguard]   Instruction = [75]
aload_2 v2   [proguard]   Exception  
= [java.lang.IllegalArgumentException] (Value is not a reference value
[proguard.evaluation.value.UnknownIntegerValue])
[proguard] Unexpected error while
performing partial evaluation: 
[proguard]   Class       =
[org/apache/commons/fileupload/util/Streams]
[proguard]   Method      =
[copy(Ljava/io/InputStream;Ljava/io/OutputStream;Z[B)J]
[proguard]   Exception   =
[java.lang.IllegalArgumentException]
(Value is not a reference value
[proguard.evaluation.value.UnknownIntegerValue])

I'm having a hard time finding information about what this error can mean.

Has anyone else seen something similar?

Update

While changing the signature appeared to solve the issue, I was getting a runtime crash:

I/dalvikvm(30523): Could not find method a.b.a.b.d.b, referenced from method a.b.a.b.d.a
W/dalvikvm(30523): VFY: unable to resolve direct method 440: La/b/a/b/d;.b (Ljava/lang/String;[BII)La/b/a/b/a;
D/dalvikvm(30523): VFY: replacing opcode 0x70 at 0x0039
D/dalvikvm(30523): VFY: dead code 0x003c-0041 in La/b/a/b/d;.a (Ljava/lang/String;[BII)[La/b/a/b/a;
W/dalvikvm(30523): VFY: 'this' arg 'Ljava/lang/Object;' not instance of 'Ljava/io/InputStream;'
W/dalvikvm(30523): VFY:  rejecting opcode 0x6e at 0x0045
W/dalvikvm(30523): VFY:  rejected La/b/a/a/a/b;.a (La/b/a/b/a/a;La/b/a/a;)La/b/a/a/a/c;
W/dalvikvm(30523): Verifier rejected class La/b/a/a/a/b;
W/dalvikvm(30523): threadid=10: thread exiting with uncaught exception (group=0x400259f8)

I started reading more of the Proguard manual, and found by adding -dontoptimize, the build-time errors and runtime crashes go away. Sort of defeats the purpose of using Proguard, doesn't it?

-Kevin

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暖风昔人 2024-10-23 21:30:49

该错误表明 ProGuard 的优化步骤存在错误。您应该确保您使用的是最新版本(在撰写本文时为 ProGuard 4.5.1 或 4.6 beta3)。如果问题仍然存在,您应该在 ProGuard 错误跟踪器中提交错误报告,并提供一个可以重现问题的小示例项目。

The error suggests that there is a bug in ProGuard's optimization step. You should make sure you are using the latest version (ProGuard 4.5.1 or 4.6 beta3 at this time of writing). If the problem persists, you should file a bug report in the ProGuard bug tracker, with a small sample project that allows to reproduce the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文