Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse: Conversion to Dalvik format failed with error 1

This happens instantly when I make a new project in Eclipse.

I only have 1 jar file in the project, I have tried to remove it, and add it again, several times, and cleaned the project after this.

I have updated ProGuard (I think), downloaded the new version, and replaced the lib folder as the threads on here said.

My default.properties file looks like this:

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-8

So can't comment anything about ProGuard which was also mentioned in another thread. I feel I have tried everything, and still this bug. One thing I have noticed though if I go to: window -> preferences -> android -> build. And uncheck "Force error when external jars contain native libraries". Then I get: "Can't resolve R" instead of the Dalvik error.

There is no import named android.R either.

Anyone with some help please?

like image 403
Anders Metnik Avatar asked Sep 26 '11 13:09

Anders Metnik


4 Answers

This doesn't look like the issue with proguard, since it's not even enabled in your defaults.properties file. Try the following:

  1. Uncheck "Force error when external jars contain native libraries" option (just as you did)
  2. Select "Project -> Clean…" from the menu
  3. If that won't help ensure you have the correct R class imported. As stated at source.android.com:

    Eclipse sometimes likes to add an import android.R statement at the top of your files that use resources, especially when you ask eclipse to sort or otherwise manage imports. This will cause your make to break. Look out for these erroneous import statements and delete them.

UPDATE

Have a look also at this thread: "Conversion to Dalvik format failed with error 1" on external JAR.
Check the following answers (link will bring you directly to the answer):

  • michel's answer
  • user408841's answer
  • Mido's answer
  • Joe's Apps' answer
like image 97
Idolon Avatar answered Oct 29 '22 23:10

Idolon


I had mistakenly added a reference to a copy of android.jar, which was not required as it is an android dependency, I removed this and the error went away.

like image 38
John Avatar answered Oct 30 '22 00:10

John


I started having this problem as well... The only thing that fixed it for me was manually downlaoding the newest version of ProGuard (currently 4.6) and replacing the SDK's version of Proguard's bin and lib folders with the newest verison.

After that everything started working again. This is apparently a logged bug... http://code.google.com/p/android/issues/detail?id=18359

like image 2
Justin Avatar answered Oct 29 '22 23:10

Justin


Do you have the new Android SDK? If you do, you have to download the proguard.jar from the proguard website and replace it on the SDK directory.

like image 1
neteinstein Avatar answered Oct 30 '22 00:10

neteinstein