gpt4 book ai didi

android - 使用 android "Unexpected error while evaluating instruction"运行混淆器时出现奇怪错误

转载 作者:搜寻专家 更新时间:2023-11-01 09:14:00 25 4
gpt4 key购买 nike

在使用 android 运行 proguard 时,我遇到了一个奇怪的错误。这个错误意味着什么,有什么办法可以解决这个问题,

我使用的是 ProGuard,版本 4.4安卓 2.3.1

2011-05-17 17:55:25 - tests] Optimizing...
[2011-05-17 17:55:25 - tests] Proguard returned with error code 1. See console
[2011-05-17 17:55:25 - tests] Unexpected error while evaluating instruction:
[2011-05-17 17:55:25 - tests] Class = [com/test/service/DownloadBarCodeService]
[2011-05-17 17:55:25 - tests] Method = [onHandleIntent(Landroid/content/Intent;)V]
[2011-05-17 17:55:25 - tests] Instruction = [170] iload v14
[2011-05-17 17:55:25 - tests] Exception = [java.lang.NullPointerException] (null)
[2011-05-17 17:55:25 - tests] Unexpected error while performing partial evaluation:
[2011-05-17 17:55:25 - tests] Class = [com/test/service/DownloadBarCodeService]
[2011-05-17 17:55:25 - tests] Method = [onHandleIntent(Landroid/content/Intent;)V]
[2011-05-17 17:55:25 - tests] Exception = [java.lang.NullPointerException] (null)
[2011-05-17 17:55:25 - tests] java.lang.NullPointerException
[2011-05-17 17:55:25 - tests] at proguard.evaluation.Variables.iload(Variables.java:228)
[2011-05-17 17:55:25 - tests] at proguard.evaluation.Processor.visitVariableInstruction(Processor.java:645)
[2011-05-17 17:55:25 - tests] at proguard.classfile.instruction.VariableInstruction.accept(VariableInstruction.java:306)
[2011-05-17 17:55:25 - tests] at proguard.optimize.evaluation.PartialEvaluator.evaluateSingleInstructionBlock(PartialEvaluator.java:729)
[2011-05-17 17:55:25 - tests] at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlock(PartialEvaluator.java:575)
[2011-05-17 17:55:25 - tests] at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlockAndExceptionHandlers(PartialEvaluator.java:533)
[2011-05-17 17:55:25 - tests] at proguard.optimize.evaluation.PartialEvaluator.visitCodeAttribute0(PartialEvaluator.java:221)
[2011-05-17 17:55:25 - tests] at proguard.optimize.evaluation.PartialEvaluator.visitCodeAttribute(PartialEvaluator.java:180)
[2011-05-17 17:55:25 - tests] at proguard.optimize.evaluation.LivenessAnalyzer.visitCodeAttribute(LivenessAnalyzer.java:195)
[2011-05-17 17:55:25 - tests] at proguard.optimize.evaluation.VariableOptimizer.visitCodeAttribute(VariableOptimizer.java:102)
[2011-05-17 17:55:25 - tests] at proguard.classfile.attribute.CodeAttribute.accept(CodeAttribute.java:101)
[2011-05-17 17:55:25 - tests] at proguard.classfile.ProgramMethod.attributesAccept(ProgramMethod.java:79)
[2011-05-17 17:55:25 - tests] at proguard.classfile.attribute.visitor.AllAttributeVisitor.visitProgramMember(AllAttributeVisitor.java:95)
[2011-05-17 17:55:25 - tests] at proguard.classfile.util.SimplifiedVisitor.visitProgramMethod(SimplifiedVisitor.java:91)
[2011-05-17 17:55:25 - tests] at proguard.classfile.ProgramMethod.accept(ProgramMethod.java:71)
[2011-05-17 17:55:25 - tests] at proguard.classfile.ProgramClass.methodsAccept(ProgramClass.java:439)
[2011-05-17 17:55:25 - tests] at proguard.classfile.visitor.AllMethodVisitor.visitProgramClass(AllMethodVisitor.java:47)
[2011-05-17 17:55:25 - tests] at proguard.classfile.ProgramClass.accept(ProgramClass.java:281)
[2011-05-17 17:55:25 - tests] at proguard.classfile.ClassPool.classesAccept(ClassPool.java:114)
[2011-05-17 17:55:25 - tests] at proguard.optimize.Optimizer.execute(Optimizer.java:764)
[2011-05-17 17:55:25 - tests] at proguard.ProGuard.optimize(ProGuard.java:325)
[2011-05-17 17:55:25 - tests] at proguard.ProGuard.execute(ProGuard.java:114)
[2011-05-17 17:55:25 - tests] at proguard.ProGuard.main(ProGuard.java:499)

最佳答案

我遇到了同样的问题。这是原始代码:

    boolean mExternalStorageAvailable = false;
boolean mExternalStorageWriteable = false;
String state = Environment.getExternalStorageState();

if (Environment.MEDIA_MOUNTED.equals(state)) {
// We can read and write the media
mExternalStorageAvailable = true;
mExternalStorageWriteable = true;
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
// We can only read the media
mExternalStorageAvailable = true;
mExternalStorageWriteable = false;
} else {
// Something else is wrong. It may be one of many other states, but
// all we need to know is we can neither read nor write
mExternalStorageAvailable = false;
mExternalStorageWriteable = false;
}

return (mExternalStorageAvailable && mExternalStorageWriteable);

Proguard 最后一行有问题!我最终得到了 2 个解决方案。

解决方案#1:不在开头初始化 2 个 bool 变量:

boolean mExternalStorageAvailable;
boolean mExternalStorageWriteable;
String state = Environment.getExternalStorageState();

if (Environment.MEDIA_MOUNTED.equals(state)) {
// We can read and write the media
mExternalStorageAvailable = true;
mExternalStorageWriteable = true;
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
// We can only read the media
mExternalStorageAvailable = true;
mExternalStorageWriteable = false;
} else {
// Something else is wrong. It may be one of many other states, but
// all we need to know is we can neither read nor write
mExternalStorageAvailable = false;
mExternalStorageWriteable = false;
}

return (mExternalStorageAvailable && mExternalStorageWriteable);

解决方案 #2 是返回 true/false 而不是设置 2 个 bool 值。

String state = Environment.getExternalStorageState();

if (Environment.MEDIA_MOUNTED.equals(state)) {
// We can read and write the media
return true;
} else {
return false;
}

对于这种情况,它工作正常(并且可能更好),但我很高兴我没有在更复杂的函数中遇到这个问题!

关于android - 使用 android "Unexpected error while evaluating instruction"运行混淆器时出现奇怪错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6030972/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com