Question

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?

Was it helpful?

Solution 2

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!

OTHER TIPS

"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 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 { *; }

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top