Reputation: 6395
I'm getting following strange error when running the proguard with android.what this error means,is there any way to fix this issue,
I'm using the ProGuard, version 4.4 Android 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)
Upvotes: 2
Views: 2753
Reputation: 10980
Faced the same issue after updating to (beta) version 4.10 of ProGuard in combination with the Android SDK.
The solution to not set initialize the boolean variables solved my proguard exceptions!
Upvotes: 0
Reputation: 424
Put this in your project's project.prperties file
proguard.config=/PROJECT NAME IN ECLIPSE/proguard.cfg
Upvotes: -3
Reputation: 1705
I had the same problem. here's the original code:
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 had problems with the last line! I ended up with 2 solutions.
Solution #1: not to initialize the 2 boolean variables at the begining:
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);
Solution #2 is return true/false instead of setting the 2 boolean values.
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
// We can read and write the media
return true;
} else {
return false;
}
This works fine (and might be better) for this case, but I'm happy I didn't get this problem in a more complex function!
Upvotes: 4
Reputation: 723
For the record, I'm having the same problem. Have you found a solution?
Edit:
I have managed to nail it down to the two if-statements below. If I comment out either of the if-statements, Proguard succeeds and does not throw the NullPointerException
.
boolean externalStorageAvailable = false;
boolean externalStorageWriteable = false;
...
if (!externalStorageAvailable) {
throw new IOException("External storage is not available");
}
if (!externalStorageWriteable) {
throw new IOException("Could not get write access to external storage");
}
And if I invert and the boolean values and assign them to new variables, Proguard also succeeds. That works for me.
boolean externalStorageAvailable = false;
boolean externalStorageWriteable = false;
...
boolean notAvailable = !externalStorageAvailable;
boolean notWritable = !externalStorageWriteable;
if (notAvailable) {
throw new IOException("External storage is not available");
}
if (notWritable) {
throw new IOException("Could not get write access to external storage");
}
Upvotes: 0
Reputation: 45668
Chances are that this problem has been fixed in the latest release of ProGuard, version 4.6 at this time of writing. Otherwise, you can file a bug report on the ProGuard site at Sourceforge, preferably with a simple test case that allows to reproduce the problem.
Upvotes: 2