NoClassDefFoundError - GameHelper Google Games - android

Using Eclipse IDE
Following the: https://developers.google.com/games/services/android/quickstart
Using the copy of google-play-services_lib (as recommended) and imported as Eclipse project.
Editing the game manifest with:
Adding our APP ID to res/values/strings.xml
Linked google-play-services_lib with our game project and set references in Order and Export tabs in the project settings
In accordance with https://developers.google.com/games/services/android/init using the project BaseGameUtils, from which our activity cannot inherit, because there’s another class already.
So, we moved to the second method without inheriting (see Using GameHelper without BaseGameActivity). We linked google-play-services_lib for BaseGameUtils and set the Library (compilation went down OK).
Linking added to our project to be able to use GameHelper as well as google-play-services_lib.
At this moment SDK from Facebook started causing trouble, so we had to add android-support-v4.jar (used by BaseGameUtils as well) and error during compilation occurs:
Found 2 versions of android-support-v4.jar in the dependency list,
but not all the versions are identical (check is based on SHA-1 only at this time).
All versions of the libraries must be the same at this time.
Versions found are:
Path: /Users/travis/Work/Craneballs/Mafia_android/facebook-android-sdk/facebook/libs/android-support-v4.jar
Path: /Users/travis/Work/Craneballs/Mafia_android/BaseGameUtils/libs/android-support-v4.jar
the project can be launched, but crashes on GoogleHelper = new GameHelper(this, GameHelper.CLIENT_ALL)
with the error message: java.lang.NoClassDefFoundError: com.google.example.games.basegameutils.GameHelper
I’ve spent many painful hours on this and am at my wits end. Any ideas?

I was having the same problem.
Here's the solution that fixed it for me:
I had the same issue, I did the following to fix the problem.
Go to "Properties" of the project.
Select "Java Build Path"
Select "Order and Export" Tab
You should see the selected project's "src" and "gen" paths and dependencies here.
The order how they listed were first "src" and then "gen" path
I switch them, so that "gen" folder is build before the "src"
gen - automated code in project (from dependencies and references)
src - source code in project
There was no need to restart the Eclipse. It just started working.
Honestly I have never tried "Android Tools > Fix Project Properties", sometimes it might be doing the same thing. I do not know, I just did above after seen the error message, thinking something is wrong with the build paths.
Resources that might help...
NoClassDefFoundError for code in an Java library on Android
Android app crashes after SDK-tools update version (NoClassDefFound, tool version 22)

Related

How to edit build path entries in Eclipse?

So I have been having trouble with the Android Support Library with respect to a Jar mismatch or the like where for some reason I was having trouble extending the ActionBarActivity as it was giving the error that appcompat_v7.apk could not be found.
Hence I deleted the original library I had in my Eclipse projects and reinstalled the Support Library, attaching it to my project of interest with these instructions. Note that following these instructions, the new project folder is now "android-support-v7-appcompat" rather than the original "appcompat_v7".
Following this, I have tried several times to clean my project, quit and reenter Eclipse, but I still come up with two problems stating: "The project cannot be built until build path errors are resolved" and "'ProjectName' is missing required Java project: 'appcompat_v7'".
However, when going to Project --> Properties --> Java Build Path, under "Order and Export" a folder named "appcompat_v7" is shown as missing, though the other jars of interest are present, as can be seen in this screenshot:
What can I do to delete or edit this build path entry? To be clear, at this point my project will not even compile, although prior to my deleting the original appcompat_v7 folder it was able to compile but not load any Activity that extended the ActionBarActivity. I would love to be able to compile my code again -_-
The folder icon next to "appcompat_v7" indicates that it is a project. You should remove it from the "Projects" tab.

android dalvik error 1 with library project [duplicate]

In my Android application in Eclipse, I get the following error.
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lorg/xmlpull/v1/XmlPullParser;
....
Conversion to Dalvik format failed with error 1
This error only appears when I add a specific external JAR file to my project. I searched for a long time for a possible solution, but none of them work.
I even tried to change to Android 1.6 instead of 1.5 (the current version I use).
Go to Project » Properties » Java Build Path » Libraries and remove all except the "Android X.Y" (in my case Android 1.5). click OK. Go to Project » Clean » Clean projects selected below » select your project and click OK. That should work.
It is also possible that you have a JAR file located somewhere in your project folders (I had copied the Admob JAR file into my src folder) and THEN added it as a Java Path Library. It does not show up under the Package Explorer, so you don't notice it, but it does get counted twice, causing the dreaded Dalvik error 1.
Another possible reason could be package name conflicts. Suppose you have a package com.abc.xyz and a class named A.java inside this package, and another library project (which is added to the dependency of this project) which contains the same com.abc.xyz.A.java, then you will be getting the exact same error. This means, you have multiple references to the same file A.java and can't properly build it.
In other ways this may be occurred if you accidentally or knowingly edit/ add any thing in the class path file manually .In certain cases we may add android.jar path manually to classpath file for generating java doc.On removing the that after javadoc generated code will works fine.Please check this too if any one still occurs.
I solved the problem.
This is a JAR file conflict.
It seems that I have two JAR files on my buildpath that include the same package and classes.
smack.jar and android_maps_lib-1.0.2
Deleting this package from one of the JAR files solved the problem.
Windows 7 Solution:
Confirmed the problem is caused by ProGuard command line in the file
[Android SDK Installation Directory]\tools\proguard\bin\proguard.bat
Edit the following line will solve the problem:
call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %*
to
call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
You can solve this issue easily (with Eclipse Android Developer Tools, Build: v22.0.1-685705) by turn off menu > "Project" > "Build Automatically" while exporting (un)signed Android application. After that, don't forget to turn it on again.
If you have ADT revision 12+, you should update your proguard from 4.4 -> 4.6 (as described here). Also, you should leave ...\bin\proguard.bat file in the orginal form.
Just download it from the web, and copy lib folder from downloaded package to the :
[Android SDK Installation Directory]\tools\proguard\lib
EDIT (new solution):
It looks like the previous solution is only a bypass. I managed to finally fix the problem permanently:
In my case there was a mismatch in android-support-v4 files in my project and in the Facebook project that is referenced in my project.
I found this error by performing Lint Check (Android Tools / Run Lint: Check for Common Errors)
My previous solution:
I've tried any possible solution on this site - nothing helped!!!
Finally I've found an answer here:
https://groups.google.com/forum/#!topic/actionbarsherlock/drzI7pEvKd4
Easy steps:
Go to Project -> uncheck Build Automatically
Go to Project -> Clean... , clean both the library project and your
app project
Export your app as a signed APK while Build Automatically is still
disabled
Here's another scenario, and solution:
If you run into this problem recently after updating the ADT for Eclipse:
In your app project, check for any linked source folders pointing to your library projects (they have names in the form "LibraryName_src").
Select all those projects, right-click, choose "Build Path"->"Remove from Build Path".
Choose "Also unlink the folder from the project", and click "Yes".
Clean, rebuild and redeploy the project.
It seems the reason is that some previous version of ADT linked Library project source folders to the "child" projects, and the current ADT/Dex combination isn't compatible with that solution anymore.
EDIT: this is confirmed by an Android Dev Blog entry, specifically this one - see the 8th paragraph onwards.
Go to Project and then uncheck "Build Automatically".Then try to export the project and the error is gone.
This can also be caused if you have added Android.jar file to your build path, perhaps by an accidental quick fix in Eclipse. Remove it with right clicking Project -> build path -> configure build path -> android.jar, remove.
Simply cleaning the project has worked for me every time this error has come up.
My own and only solution that I found today after four hours of testing all the solutions, is a combination of many solutions provided here:
Delete project from Eclipse
Delete files in \bin and \gen from project folder
Remove references to libraries into .classpath file in root project folder
Restart Eclipse with command line : eclipse -clean
Import project
Right click on project - select Properties > Java Build Path > Libraries and remove everything else than Android XX.Y
Finally clean project, wait for automatic Building or Build it
Launch and now it works! At least for me...
I tried every step at a time and many combinations, but only the succession of all steps at once made it! I hope I won't face this again...
Just for the other people who still have this problem and they have tried the above answers but still getting the error (which was my case), then my solution was to delete the project from Eclipse and re-import it again.
This made the Android library to be added again to my referenced libraries, so now I have two Android JAR files referenced, hence I deleted one of them and now it compiles fine.
Solution: Delete the project from Eclipse IDE and then re-import it again, then check for the above solutions.
Ran into this problem myself today. Cleaning and rebuild did not fix the problem. Deleting and reimporting the project didn't help either.
I finally traced it back to a bad additions to my .class file. I think this was added by the plugin tools when I was trying to fix another problem, removing it got rid of the "Conversion to Dalvik format failed with error 1" build error:
<classpathentry kind="lib" path="C:/dev/repository/android-sdk-windows/platforms/android-3/android.jar">
<attributes>
<attribute name="javadoc_location" value="file:/C:/dev/repository/android-sdk-windows/docs/reference"/>
</attributes>
<accessrules>
<accessrule kind="nonaccessible" pattern="com/android/internal/**"/>
</accessrules>
For me, an extra JAR reference had appeared in my build path. I deleted this, and it works now.
My problem was caused by ADT version 12.0 and ProGuard integration.
This bug is well documented and the solution is in the documentation
Solution is in here
ProGuard command line
Updating Proguard to latest version solved it for me.
My proguard path was C:\Program Files (x86)\Android\android-sdk\tools\proguard\
I downloaded the new version from here
and replaced both bin and lib folders
THANK GOD!
I've dealt with this problem when using Sherlock ActionBar library in my project.
You could do the following step, it's work for me.
Right click to your project, select properties.
A dialog will show up, select 'Java build path' on the left menu.
Remove 'Android dependencies' and 'Android private libraries' on the right panel then click OK
Clean your project (select menu Project --> Clean)
Right click your project, select Android Tools -> Fix project properties
Clean project once again.
Restart your computer
Open eclipse and Export apk
Hope that will help you.
In my case the problem is actually with OpenFeint API project. I have added OpenFeint as library project:
.
It is also added into build path, ADT tools 16 gives error with this sceneario.
Right click on your project and click build path, configure the build path and then see the image and remove your project OpenFeint from here and all is done :)
I found something else. Android uses the /libs directory for JAR files. I have seen the "Conversion to Dalvik format failed with error 1" error numerous times, always when I made a mistake in my JAR files.
Now I upgraded Roboguice to a newer version, by putting the new JAR file in the /libs directory and switching the class path to the new version. That caused the Dalvik error.
When I removed one of the Roboguice JAR files from the /libs folder, the error disappeared. Apparently, Android picks up all JAR files from /libs, regardless of which ones you specify in the Java build path. I don't remember exactly, but I think Android started using /libs by default starting with Android 4.0 (Ice Cream Sandwich, ICS).
In general, it seems that this problem comes when there are unnecessary JAR files in build path.
I faced this problem while working on IntelliJ IDEA. For me it happened because I added JUnit and Mockito libraries which were being compiled at runtime. This needed to be set to "testing" in module properties.
None of previously proposed solutions worked for me. In my case, the problem happened when I switched from referencing a library source code folder to using the library JAR file.
Initially there was an Android library project listed under the Android application project Properties\ Android page\ Library section, and the library compared also in project explorer tree as a link to the library source directory.
In the first place, I just deleted the directory link from the project tree and I added the JAR library to the build path, but this caused the exception.
The correct procedure was (after changing back the build path and putting back the reference to the library source):
properly remove the library source directory link by actually removing the reference from application project Properties\ Android page
adding the library JAR to the application project build path as usual.
None of the listed solutions worked for me.
Here's where I was having a problem:
I added the jSoup external JAR file to my project's path by first putting it in a source folder called "libs", and then right clicking on it, Build Path -> add to build path. This threw the Dalvik conversion error. It said I had "already included" a class from that JAR file. I looked around the project's directory and found that the place where it was "already included" was in fact the bin directory. I deleted the JAR file from the bin directory and refreshed the project in Eclipse and the error went away!
All the solutions above didn't work for me. I'm not using any precompiled .jar. I'm using the LVL and the Dalvik errors where all related to the market licensing library.
The problem got solved by deleting the main project and reimporting (create a new project from existing sources).
I had the same problem and none of these solutions worked.
Finally, I saw in the console that the error was due to duplicated class (one in the existing project, one in the added jar file) :
java.lang.IllegalArgumentException: already added: package/MyClassclass;
[2011-01-19 14:54:05 - ...]: Dx1 error; aborting
[2011-01-19 14:54:05 - ...] Conversion to Dalvik format failed with error 1
So check if you are adding jar with duplicated classes in your project.
If yes, try removing one of them.
It worked for me.
Often for me, cleaning the project DOES NOT fix this problem.
But closing the project in Eclipse and then re-opening it does seem to fix it in those cases...
I ran into this problem but my solution was twofold.
1.) I had to add an Android target version under project -> properties -> Android.
2.) I didn't have all google 'third party add-ons'. Click in AVD SDK manager under available packages -> third-party add-ons -> Google Inc. I downloaded all of the SDKs and that solved my issue.
I am using Android 1.6 and had one external JAR file. What worked for me was to remove all libraries, right-click project and select Android Tools -> *Fix Project Properties (which added back Android 1.6) and then add back the external JAR file.
I ran into this problem because the Android-Maven-plugin in Eclipse was apparently not recognizing transitive references and references referenced twice from a couple of projects (including an Android library project), and including them more than once. I had to use hocus-pocus to get everything included only once, even though Maven is supposed to take care of all this.
For example, I had a core library globalmentor-core, that was also used by globalmentor-google and globalmentor-android (the latter of which is an Android library). In the globalmentor-android pom.xml I had to mark the dependency as "provided" as well as excluded from other libraries in which it was transitively included:
<dependency>
<groupId>com.globalmentor</groupId>
<artifactId>globalmentor-core</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- android-maven-plugin can't seem to automatically keep this from being
included twice; it must therefore be included manually (either explicitly
or transitively) in dependent projects -->
<scope>provided</scope>
</dependency>
Then in the final application pom.xml I had to use the right trickery to allow only one inclusion path---as well as not explicitly including the core library:
<!-- android-maven-plugin can't seem to automatically keep this from being
included twice -->
<!-- <dependency> -->
<!-- <groupId>com.globalmentor</groupId> -->
<!-- <artifactId>globalmentor-core</artifactId> -->
<!-- <version>1.0-SNAPSHOT</version> -->
<!-- </dependency> -->
<dependency>
<groupId>com.globalmentor</groupId>
<artifactId>globalmentor-google</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<!-- android-maven-plugin can't seem to automatically keep this from
being included twice -->
<exclusion>
<groupId>com.globalmentor</groupId>
<artifactId>globalmentor-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.globalmentor</groupId>
<artifactId>globalmentor-android</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
In my case
project->properties->java build path -> in order and export tab -> uncheck android-support-v4.jar
Just clean the project
If this does not work try the other solutions

Unable to Debug Library Projects with ADT v14 - Source Not Found

Ever since upgrading my current projects to use the new R14 Tools in Eclipse, I'm now unable to debug any code that exists in my library projects.
When I hit a break point in my library project code, instead of Eclipse opening the original source file, it opens up the read-only copy of the source file contained within the JAR with the message "Source not found".
I've searched around for a solution to this, but have yet to come across anything. Does anybody else have any suggestions? It's quite a pain not being able to debug.
EDIT
The issue has came back and I'm no longer able to debug. I haven't changed any project settings around or anything. Very frustrating.
Tried all of the above and it did not work for me, however the workaround detailed here did.
http://code.google.com/p/android/issues/detail?id=20731
Start debugging, and run until you hit a breakpoint (and precisely get a .class file instead of the .java you would like to have)
Right click in the Debug view of the Debug perspective (for example on the call stack), and choose "Edit Source Lookup Path"
Add all your projects above "Default", via "Add..." > "Java project" > "Select All"
(I'm using ADT 15.0.2 preview from http://tools.android.com/download)
After having this issue as well and doing a little research, I came across this thread and another one that tipped me off. I was pulling my hair out already.
It turns out that the problem is with the build order of your projects (mine was anyway). Since ADT/SDK v14 changed the way library projects are referenced, the build order needs to be correct. Make sure all of the libraries your app uses are built first. I just moved the "src" and "gen" folders for each of my projects to the bottom and now it builds the library first and I am able to debug it and view the source of my library files through the main project.
In case someone doesn't know where to do this, in Eclipse, right click on your project and "Build Path" and then click "Configure Build Path". Then, on the "Order and Export" tab, move the two folders for your project to the bottom of the list below your libraries. I did this for all of my projects and the library projects.
You can also do it globally in Eclipse from Windows->Preferences->General->Workspace->Build Order and moving your library projects to the top. I think the build order defined in each project will override this though, so you may want to do it in both places to solve the issue now and for future projects.
I had the same problem in a project today. The project consists of an app which has two library dependencies. I could not see code during debugging and when using auto-completion when overriding methods Eclipse was unable to deduce proper argument names.
First of all, the problem manifested itself by showing the the 'gen' folder was used as the one that contained the source. To check whether this is the same issue go to your app project, open the Android dependencies and have a look at the properties of the your library dependencies. Location path said /libraryprojectname/gen.
If this is also your problem then go to the 'Order and Export' tab of each library project and move the 'gen' item below the 'src' item. As soon as you click OK Eclipse will work a bit and when you check the Android dependency properties the location path should say: /libraryprojectname/src. Open click the dependency and open any class inside the jar. It should show the source.
I am using ADT plugin 20.0.3 with Android SDK Tools 20.0.3 and Android SDK Platform Tools 14.
The following worked for me on Eclipse Juno:
In Project Properties/Java Build Path:
In the Projects tab, added my library projects.
In the Order and Export tab, moved my library projects to the top, and checked them
Not sure if it's relevant, but Android SDK tools is rev 20.0.3 and Android SDK platform tools is 14.
I assume you are opeining library project and there you put brakepoint.
Try this: On main project open Library Projects->[yourlibrary.jar]->[yourfile.class] from Package Explorer, and then in .class file put brakepoints.
This works for me at least :)
Sometimes this happens to me. Not sure about the reason but the way I solve is:
Remove the main project from eclipse. -- Closs Eclipse -- Delete the jar file in the library project -- Open Eclipse -- Wait for the library project to compile -- Import the main project
This problem also occurs with release 21 of ADT inside Juno. As a workaround, in the "debug" view of the debug perspective (where you see threads and method invocation traces), right click and edit source lookup path.

Cannot build library dependent project after update to ADT 14

In order to implement different versions of our UI we broke our program up into UI specific code and a common library project that has everything else. Up until yesterday when I updated to ADT 14 everything was working fine. Now I can't build. I keep getting the error "The container 'Library Projects' references non existing library 'path to the bin folder of my common project and the name of the project.jar'
I've been all over the web and tried everything I can think of to fix this to no avail. Can someone help me out? I'm basically stuck at this point.
Maybe you have the same issues I had when switching to the new ADT:
In my previous setup I had some resources split between the library and the main project. The library project would not compile error free on its own but only in combination with the main project which added the missing resources.
It doesn't work like this any more.
The library project must compile completely error free now. When it does the build process will create a <lib_project_name>.jar in the bin folder of the library project.
If the jar file is not created ( thus the build process of the library project failed for some reason - eg. because the changes in the R.java file (see http://tools.android.com/recent/buildchangesinrevision14 )) you will get the error message you described.
Also, I had to manually remove the <lib_project>_src from the project.
I've had a problem with a few different projects where I did the fixes suggested in the other answer, but they were only fixed temporarily.
Every time I reopened Eclipse or did a Clean on a project, the "Library Projects" directory would disappear, and I would have to open the project properties, remove the library, and add it again.
I solved this the hard way by creating a new project and copying everything into it.
Then I found an easy way to solve it. Right click the project, Refactor-->Rename. You can rename it back afterwards. This fixed it.
Check out the article "Changes to Library Projects in Android SDK Tools, r14" ( http://android-developers.blogspot.com/2011/10/changes-to-library-projects-in-android.html ) on the Android Developers blog.
E.g. #P.Melch: "I had to manually remove the _src from the project" should be done as follows:
To fix the project, you must remove the extraneous source folders with the following steps:
Right click source folder and choose Build Path > Remove from Build
path.
A dialog will pop up. In it, make sure to check “Also unlink the folder from the project” to completely remove the folder.
You have to update the Android SDK in Android SDK Manager
Android SDK Tools Intalled
Android SDK Plataforms Installed
Android SDK Builds Installed

"Conversion to Dalvik format failed with error 1" on external JAR

In my Android application in Eclipse, I get the following error.
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lorg/xmlpull/v1/XmlPullParser;
....
Conversion to Dalvik format failed with error 1
This error only appears when I add a specific external JAR file to my project. I searched for a long time for a possible solution, but none of them work.
I even tried to change to Android 1.6 instead of 1.5 (the current version I use).
Go to Project » Properties » Java Build Path » Libraries and remove all except the "Android X.Y" (in my case Android 1.5). click OK. Go to Project » Clean » Clean projects selected below » select your project and click OK. That should work.
It is also possible that you have a JAR file located somewhere in your project folders (I had copied the Admob JAR file into my src folder) and THEN added it as a Java Path Library. It does not show up under the Package Explorer, so you don't notice it, but it does get counted twice, causing the dreaded Dalvik error 1.
Another possible reason could be package name conflicts. Suppose you have a package com.abc.xyz and a class named A.java inside this package, and another library project (which is added to the dependency of this project) which contains the same com.abc.xyz.A.java, then you will be getting the exact same error. This means, you have multiple references to the same file A.java and can't properly build it.
In other ways this may be occurred if you accidentally or knowingly edit/ add any thing in the class path file manually .In certain cases we may add android.jar path manually to classpath file for generating java doc.On removing the that after javadoc generated code will works fine.Please check this too if any one still occurs.
I solved the problem.
This is a JAR file conflict.
It seems that I have two JAR files on my buildpath that include the same package and classes.
smack.jar and android_maps_lib-1.0.2
Deleting this package from one of the JAR files solved the problem.
Windows 7 Solution:
Confirmed the problem is caused by ProGuard command line in the file
[Android SDK Installation Directory]\tools\proguard\bin\proguard.bat
Edit the following line will solve the problem:
call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %*
to
call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
You can solve this issue easily (with Eclipse Android Developer Tools, Build: v22.0.1-685705) by turn off menu > "Project" > "Build Automatically" while exporting (un)signed Android application. After that, don't forget to turn it on again.
If you have ADT revision 12+, you should update your proguard from 4.4 -> 4.6 (as described here). Also, you should leave ...\bin\proguard.bat file in the orginal form.
Just download it from the web, and copy lib folder from downloaded package to the :
[Android SDK Installation Directory]\tools\proguard\lib
EDIT (new solution):
It looks like the previous solution is only a bypass. I managed to finally fix the problem permanently:
In my case there was a mismatch in android-support-v4 files in my project and in the Facebook project that is referenced in my project.
I found this error by performing Lint Check (Android Tools / Run Lint: Check for Common Errors)
My previous solution:
I've tried any possible solution on this site - nothing helped!!!
Finally I've found an answer here:
https://groups.google.com/forum/#!topic/actionbarsherlock/drzI7pEvKd4
Easy steps:
Go to Project -> uncheck Build Automatically
Go to Project -> Clean... , clean both the library project and your
app project
Export your app as a signed APK while Build Automatically is still
disabled
Here's another scenario, and solution:
If you run into this problem recently after updating the ADT for Eclipse:
In your app project, check for any linked source folders pointing to your library projects (they have names in the form "LibraryName_src").
Select all those projects, right-click, choose "Build Path"->"Remove from Build Path".
Choose "Also unlink the folder from the project", and click "Yes".
Clean, rebuild and redeploy the project.
It seems the reason is that some previous version of ADT linked Library project source folders to the "child" projects, and the current ADT/Dex combination isn't compatible with that solution anymore.
EDIT: this is confirmed by an Android Dev Blog entry, specifically this one - see the 8th paragraph onwards.
Go to Project and then uncheck "Build Automatically".Then try to export the project and the error is gone.
This can also be caused if you have added Android.jar file to your build path, perhaps by an accidental quick fix in Eclipse. Remove it with right clicking Project -> build path -> configure build path -> android.jar, remove.
Simply cleaning the project has worked for me every time this error has come up.
My own and only solution that I found today after four hours of testing all the solutions, is a combination of many solutions provided here:
Delete project from Eclipse
Delete files in \bin and \gen from project folder
Remove references to libraries into .classpath file in root project folder
Restart Eclipse with command line : eclipse -clean
Import project
Right click on project - select Properties > Java Build Path > Libraries and remove everything else than Android XX.Y
Finally clean project, wait for automatic Building or Build it
Launch and now it works! At least for me...
I tried every step at a time and many combinations, but only the succession of all steps at once made it! I hope I won't face this again...
Just for the other people who still have this problem and they have tried the above answers but still getting the error (which was my case), then my solution was to delete the project from Eclipse and re-import it again.
This made the Android library to be added again to my referenced libraries, so now I have two Android JAR files referenced, hence I deleted one of them and now it compiles fine.
Solution: Delete the project from Eclipse IDE and then re-import it again, then check for the above solutions.
Ran into this problem myself today. Cleaning and rebuild did not fix the problem. Deleting and reimporting the project didn't help either.
I finally traced it back to a bad additions to my .class file. I think this was added by the plugin tools when I was trying to fix another problem, removing it got rid of the "Conversion to Dalvik format failed with error 1" build error:
<classpathentry kind="lib" path="C:/dev/repository/android-sdk-windows/platforms/android-3/android.jar">
<attributes>
<attribute name="javadoc_location" value="file:/C:/dev/repository/android-sdk-windows/docs/reference"/>
</attributes>
<accessrules>
<accessrule kind="nonaccessible" pattern="com/android/internal/**"/>
</accessrules>
For me, an extra JAR reference had appeared in my build path. I deleted this, and it works now.
My problem was caused by ADT version 12.0 and ProGuard integration.
This bug is well documented and the solution is in the documentation
Solution is in here
ProGuard command line
Updating Proguard to latest version solved it for me.
My proguard path was C:\Program Files (x86)\Android\android-sdk\tools\proguard\
I downloaded the new version from here
and replaced both bin and lib folders
THANK GOD!
I've dealt with this problem when using Sherlock ActionBar library in my project.
You could do the following step, it's work for me.
Right click to your project, select properties.
A dialog will show up, select 'Java build path' on the left menu.
Remove 'Android dependencies' and 'Android private libraries' on the right panel then click OK
Clean your project (select menu Project --> Clean)
Right click your project, select Android Tools -> Fix project properties
Clean project once again.
Restart your computer
Open eclipse and Export apk
Hope that will help you.
In my case the problem is actually with OpenFeint API project. I have added OpenFeint as library project:
.
It is also added into build path, ADT tools 16 gives error with this sceneario.
Right click on your project and click build path, configure the build path and then see the image and remove your project OpenFeint from here and all is done :)
I found something else. Android uses the /libs directory for JAR files. I have seen the "Conversion to Dalvik format failed with error 1" error numerous times, always when I made a mistake in my JAR files.
Now I upgraded Roboguice to a newer version, by putting the new JAR file in the /libs directory and switching the class path to the new version. That caused the Dalvik error.
When I removed one of the Roboguice JAR files from the /libs folder, the error disappeared. Apparently, Android picks up all JAR files from /libs, regardless of which ones you specify in the Java build path. I don't remember exactly, but I think Android started using /libs by default starting with Android 4.0 (Ice Cream Sandwich, ICS).
In general, it seems that this problem comes when there are unnecessary JAR files in build path.
I faced this problem while working on IntelliJ IDEA. For me it happened because I added JUnit and Mockito libraries which were being compiled at runtime. This needed to be set to "testing" in module properties.
None of previously proposed solutions worked for me. In my case, the problem happened when I switched from referencing a library source code folder to using the library JAR file.
Initially there was an Android library project listed under the Android application project Properties\ Android page\ Library section, and the library compared also in project explorer tree as a link to the library source directory.
In the first place, I just deleted the directory link from the project tree and I added the JAR library to the build path, but this caused the exception.
The correct procedure was (after changing back the build path and putting back the reference to the library source):
properly remove the library source directory link by actually removing the reference from application project Properties\ Android page
adding the library JAR to the application project build path as usual.
None of the listed solutions worked for me.
Here's where I was having a problem:
I added the jSoup external JAR file to my project's path by first putting it in a source folder called "libs", and then right clicking on it, Build Path -> add to build path. This threw the Dalvik conversion error. It said I had "already included" a class from that JAR file. I looked around the project's directory and found that the place where it was "already included" was in fact the bin directory. I deleted the JAR file from the bin directory and refreshed the project in Eclipse and the error went away!
All the solutions above didn't work for me. I'm not using any precompiled .jar. I'm using the LVL and the Dalvik errors where all related to the market licensing library.
The problem got solved by deleting the main project and reimporting (create a new project from existing sources).
I had the same problem and none of these solutions worked.
Finally, I saw in the console that the error was due to duplicated class (one in the existing project, one in the added jar file) :
java.lang.IllegalArgumentException: already added: package/MyClassclass;
[2011-01-19 14:54:05 - ...]: Dx1 error; aborting
[2011-01-19 14:54:05 - ...] Conversion to Dalvik format failed with error 1
So check if you are adding jar with duplicated classes in your project.
If yes, try removing one of them.
It worked for me.
Often for me, cleaning the project DOES NOT fix this problem.
But closing the project in Eclipse and then re-opening it does seem to fix it in those cases...
I ran into this problem but my solution was twofold.
1.) I had to add an Android target version under project -> properties -> Android.
2.) I didn't have all google 'third party add-ons'. Click in AVD SDK manager under available packages -> third-party add-ons -> Google Inc. I downloaded all of the SDKs and that solved my issue.
I am using Android 1.6 and had one external JAR file. What worked for me was to remove all libraries, right-click project and select Android Tools -> *Fix Project Properties (which added back Android 1.6) and then add back the external JAR file.
I ran into this problem because the Android-Maven-plugin in Eclipse was apparently not recognizing transitive references and references referenced twice from a couple of projects (including an Android library project), and including them more than once. I had to use hocus-pocus to get everything included only once, even though Maven is supposed to take care of all this.
For example, I had a core library globalmentor-core, that was also used by globalmentor-google and globalmentor-android (the latter of which is an Android library). In the globalmentor-android pom.xml I had to mark the dependency as "provided" as well as excluded from other libraries in which it was transitively included:
<dependency>
<groupId>com.globalmentor</groupId>
<artifactId>globalmentor-core</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- android-maven-plugin can't seem to automatically keep this from being
included twice; it must therefore be included manually (either explicitly
or transitively) in dependent projects -->
<scope>provided</scope>
</dependency>
Then in the final application pom.xml I had to use the right trickery to allow only one inclusion path---as well as not explicitly including the core library:
<!-- android-maven-plugin can't seem to automatically keep this from being
included twice -->
<!-- <dependency> -->
<!-- <groupId>com.globalmentor</groupId> -->
<!-- <artifactId>globalmentor-core</artifactId> -->
<!-- <version>1.0-SNAPSHOT</version> -->
<!-- </dependency> -->
<dependency>
<groupId>com.globalmentor</groupId>
<artifactId>globalmentor-google</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<!-- android-maven-plugin can't seem to automatically keep this from
being included twice -->
<exclusion>
<groupId>com.globalmentor</groupId>
<artifactId>globalmentor-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.globalmentor</groupId>
<artifactId>globalmentor-android</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
In my case
project->properties->java build path -> in order and export tab -> uncheck android-support-v4.jar
Just clean the project
If this does not work try the other solutions

Categories

Resources