I am getting the following error when trying to run my code with ADT v21 using Eclipse Juno.
[2013-05-28 10:08:39 - XYZ] Dx
EXCEPTION FROM SIMULATION:
[2013-05-28 10:08:39 - XYZ] Dx local 000c: invalid
[2013-05-28 10:08:39 - XYZ] Dx ...at bytecode offset 00000c80
locals[0000]: Lcom/sec/x/y/z;
locals[0001]: I
locals[0002]: I
locals[0003]: Landroid/content/Intent;
locals[0004]: Ljava/lang/String;
locals[0005]: invalid
locals[0006]: Ljava/lang/String;
locals[0007]: invalid
locals[0008]: invalid
locals[0009]: invalid
locals[000a]: invalid
locals[000b]: Ljava/lang/String;
locals[000c]: invalid
locals[000d]: invalid
locals[000e]: invalid
locals[000f]: invalid
locals[0010]: invalid
locals[0011]: invalid
...while working on block 0c80
...while working on method onActivityResult IILandroid/content/Intent V
...while processing onActivityResult (IILandroid/content/Intent V
...while processing com/sec/x/y/z.class
[2013-05-28 10:09:05 - XYZ] Dx 1 error; aborting
[2013-05-28 10:09:05 - XYZ] Conversion to Dalvik format failed with error 1
This project builds perfectly on ADT v20 and below. But it is consistently giving the same error with ADT v21. The error does not occur in build stage. It occurs when I try to run the application using Eclipse.
I have read thousands of threads related to this. And none of them are working. This is not a "Clean/Build" issue for sure.
To me it seems like an Eclipse or Proguard issue. I have wasted alomst 12 hours of my life on this. Please somebody save me. Anyone with any clue on this?
"locals invalid ... Conversion to Dalvik format failed with error 1" may be caused by ProGuard's optimization step, which can't always keep the debug information about local variables consistent with the optimizations on the code.
You can avoid it by not keeping this debug information (don't specify -keepattributes LocalVariableTable).
You can work around it by disabling optimization (add -dontoptimize to your proguard-project.txt).
You can check if the most recent version of ProGuard solves the problem (replace android-sdk/tools/proguard/lib/proguard.jar with the latest version from the ProGuard site).
If updating to the latest version of ProGuard doesn't help, you can report a bug.
I resolved it myself. In onActivityResult ( where this error was getting thrown ) in one place I was not initializing an Integer variable. By initializing it, the issue got resolved. Very weird. If anyone can explain this appropriately, I'll recomend his/her answer.
Before:
int x;
After
int x = 0;
Thats it!
I think eclipse failed to recognized that initialize local variable before using it. So It does not showing warning to user while writing the code. But adt failed to compile file.
According to TanDroiD if you initialize variable your problem will be solved.
I had a similar issue, the solution was to put in a -keep class into the proguard config for the causing class. In my situation it was a class from the Fabric (Crashlytics library)
-keep class io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue { *; }
Related
I am unable to build my release product if I include kotlin-reflect with it. I attempted adding this to proguard configuration:
-keep class kotlin.reflect.** { *; }
But it did not help at all. Here is the error result from the gradle build:
Optimizing...
Unexpected error while performing partial evaluation:
Class = [kotlin/reflect/jvm/internal/impl/renderer/DescriptorRendererImpl]
Method = [renderPossiblyInnerType(Ljava/lang/StringBuilder;Lkotlin/reflect/jvm/internal/impl/descriptors/PossiblyInnerType;)V]
Exception = [java.lang.IllegalArgumentException] (Stacks have different current sizes [0] and [1])
Warning: Exception while processing task java.io.IOException: java.lang.IllegalArgumentException: Stacks have different current sizes [0] and [1]
I am using kotlin 1.1.1 (and gradle 3.3, if that matters.)
j
I had some similar errors with kotlin reflect class and proguard, solved adding in the -optimizations
!class/unboxing/enum
My bug was related to this Android Proguard failing with "Value 'i' is not a reference value"
and found the fix in one of the comments
I recently added a library to my app ('GNSDK' by Gracenote) and am now trying to build the app for release using Proguard. I successfully built and installed the release version of the app once, but all subsequent attempts produce this error:
Unexpected error while evaluating instruction:
Class = [com/gracenote/gnsdk/GnManager]
Method = [<init>(Landroid/content/Context;Ljava/lang/String;I)V]
Instruction = [87] getfield #120
Exception = [java.lang.IllegalArgumentException] (Value "i" is not a
reference value [proguard.evaluation.value.UnknownIntegerValue])
Unexpected error while performing partial evaluation:
Class = [com/gracenote/gnsdk/GnManager]
Method = [<init>(Landroid/content/Context;Ljava/lang/String;I)V]
Exception = [java.lang.IllegalArgumentException] (Value "i" is not a reference value [proguard.evaluation.value.UnknownIntegerValue])
:app:proguardBetaRelease FAILED
Error:Execution failed for task ':app:proguardBetaRelease'.
Value "i" is not a reference value [proguard.evaluation.value.UnknownIntegerValue]`
I tried to force proguard to leave the library alone (since that's the only difference between the debug and release builds) with:
-keep class com.gracenote.** {
*;
}
but it does not seem to make a difference.
Any hints on how to debug or track down this error? I am not sure why the constructor of com.gracenote.gnsdk.GnManager would be failing. The error makes it sound like it is getting an invalid input.
I'm using Android Studio 1.4, build tools 23.0.0.
I found that this is a bug in Proguard: https://sourceforge.net/p/proguard/bugs/573/
Looks like it will be released soon. In the meantime, you can work around by adding:
-optimizations !class/unboxing/enum
to your proguard file.
For what it's worth, I found this for a java project. I was running proguard targeting 1.8 when it should have been 1.9. Once I changed it it worked.
I'm currently building an android application using ANT on a Jenkins server.
DexGuard is set to run on release in the custom_rules.xml.
Currently there is an issue when DexGuard tries to convert a method:
[dexguard] Unexpected error while converting:
[dexguard] Class = [o/?]
[dexguard] Method = [?(Ljava/lang/String;)Lo/?;]
[dexguard] Exception = [java.lang.IllegalStateException] (Variable v17 too large for instruction [neg-int v17, v17])
[dexguard] java.lang.IllegalStateException: Variable v17 too large for instruction [neg-int v17, v17]
...
Stack trace
...
[dexguard] Not converting this method
My question is, is there a way to get DexGuard to exit with an error status so that either ANT or Jenkins can mark the build as failed?
At the moment it simply prints the stack trace and continues.
I am currently using the Text-finder plugin for Jenkins as a post build step to match a DexGuard exception. If found it downgrades the build to failed.
DexGuard currently ignores methods that it can't convert from Java bytecode to Dalvik bytecode, for any reason -- notably corrupt input code. In this case, it looks more like a bug in DexGuard itself. We'll fix it as soon as possible, and we'll consider adding a flag to stop with an error status.
(I am the lead developer of ProGuard and DexGuard)
My android project have Jsoup(1.6.1) as the external library, but proguard(with the default proguard.cfg generated by ADT) tells there are unexpected errors, such as:
[proguard] Unexpected error while evaluating instruction:
[proguard] Class = [org/jsoup/parser/TreeBuilder]
[proguard] Method = [insertInFosterParent(Lorg/jsoup/nodes/Node;)V]
[proguard] Instruction = [64] aload_2 v2
[proguard] Exception = [java.lang.NullPointerException] (null)
[proguard] Unexpected error while performing partial evaluation:
[proguard] Class = [org/jsoup/parser/TreeBuilder]
[proguard] Method = [insertInFosterParent(Lorg/jsoup/nodes/Node;)V]
[proguard] Exception = [java.lang.NullPointerException] (null)
I have found many posts with the similiar issue for other libraries, and -dontoptimize can remove such errors, but it would degrade the optimization (as the default value in proguard.cfg: -optimizationpasses 5)
Anyone could help me on this? or is it a potential issue of Jsoup?
I had the same issue.
Resolved it by using the latest version of Proguard (4.6) instead of the version bundled with the android sdk (4.4).
This looks like a bug in ProGuard. You should check if it hasn't been fixed in the latest release. Otherwise, you can report the bug on ProGuard's bug tracker at Sourceforge. In this case, the problem may be easy to reproduce. You can probably work around it by reducing the number of optimization passes.
I suddenly started getting an unusual compiler error and is it making impossible to do any testing, I am running Eclipse with the plugin and compiling on the 2.1 version.
[2010-08-11 00:29:38 - PeriodTrackerv2]
trouble processing "java/net/DatagramPacket.class":
[2010-08-11 00:29:38 - PeriodTrackerv2]
Attempt to include a core class (java.* or javax.*) in something other
...
[2010-08-11 00:29:38 - PeriodTrackerv2] 1 error; aborting
[2010-08-11 00:29:38 - PeriodTrackerv2] Conversion to Dalvik format failed with error 1
I verified that this class does exist in the standard Android2.1 jar file, so I find it highly unusual a class in the actual base Jar file would be problematic. I am not using this class in any fashion in my program.
I updated to version 2.2 and still get same error, this completely baffles me and just appeared tonight after zero issues for months.
Any ideas on how to fix this?
Cheers,
Tom
Alright!
I reviewed the build path and somehow the Android.jar was added twice. Problem solved.