Unable to execute dex error for android project in eclipse - android

Hi I am developing small android application using eclipse tool. I am including two jar files into my project support version-4 and another is my library jar file. When I ran my application it run successfully but i tried to use it gives me some errors regarding no class def found error. So I do to project properties and there in java build path order and export I checked two jar files. After that i clean build my project and try to run my project. SO while running my project it gives me error. Run time error is as follow:
[2013-07-08 12:19:16 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/haarman/listviewanimations/ArrayAdapter;
[2013-07-08 12:19:16 - ListViewAnimationExample] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/haarman/listviewanimations/ArrayAdapter;
I check around this problem and according solution I delete my bin and gen folder and also tried again run but it gives me same error. How to solve this problem. Is it related to my project set up or its related to eclipse? Need Help.
Thank you.

This is a build path issue. Check that your bin folder is not part of your build path. Typically you get this when you have two of the same jars, but with different versions. Are you using external libraries like ActionBarSherlock? If the android-support-v4 jar you include is a different version than the one ActionBarSherlock uses you will get this error.

Unable to execute error solution link
Also check Make sure that the value of android:targetSdkVersion in AndroidManifest.xml matches target=android- in project.properties.

Related

In Eclipse - Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/annotation/AnimRes;

I can see the same question has been asked many times, but from all the answers available I couldn't find any solution for my problem.
My project is using 2 library projects & I also have included following jar files in libs.
- android-support-v4.jar
- aws-android-sdk-core-2.1.10.jar
- aws-android-sdk-s3-2.1.10.jar
- crashlytics.jar
- gson-2.3.1.jar
- library-1.0.15.jar (For Volley)
- picasso-2.2.0.jar
While development, my app was running fine. But the moment I tried to Export, for creating signed APK file I got an error message.
"Conversion to Dalvik format failed with error 1"
In console, I checked the messages,
"Jar mismatch! Fix your dependencies
Found 3 versions of android-support-v4.jar in the dependency list, but not all the versions are identical."
In the message itself I checked that one of the android-support-v4.jar (from one of the library projects) files is different, so I replaced it with the other jar file. Now all the jar files are identical.
But now when I try to run the project I am getting one another error message
"Your project contains error(s), please fix them before running your application."
Now on checking console I see following messages.
[2015-07-15 11:23:13 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/annotation/AnimRes;
[2015-07-15 11:23:13 - MyApp] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/annotation/AnimRes;
From some answers, I found that this issue is because of to multiple occurrences of the same jar file getting added in the project.
All the included jar files are 3rd party & necessary for the project.
I have tried some of the ways suggested in other answer, but I am not able to solve this issue.
Please help me to solve it.
Finally managed to solve it.The issue was because of to multiple occurrences of the same set of classes or jar files. In my libs folder, there are 2 jar files
-gson-2.3.1.jar
-aws-android-sdk-core-2.1.10.jar
& both of these contain Gson class. In aws it is in package com.amazonaws.com.google.gson.Gson & in gson lib it is in com.google.gson.Gson.
So because of this I was getting the error message Multiple dex files define Landroid/support/annotation/AnimRes;.
Now I have removed the -gson-2.3.1.jar file from libs because it's feature, I can use from the -aws-android-sdk-core-2.1.10.jar lib.
After cleaning the project, I was able to create signed APK file.
In my case, I've removed Android Private Libraries from Project properties/Java Build Path. The result looks like at the pic
Solutions to errors conversion of dalvik failure format and error sun / misc / basecoder64 in Eclipse.
Instructions to solve the problem are:
Install Windows XP sp2 with Java 6 or Ubuntu.
Download adt version 23.0.2 with SDK 19.
Decompress the adt and install it on your computer.
Open Eclipse as administrator and import the android file.
In the file project.properties add target = android-19.
Export your project and this error will no more appear.

How to deal with multiple jar handling issue?

I have been noticing one major problem in android that
When I use/import couple of jars in my android app for development purpose so I get below exception:
[2011-10-23 16:23:29 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/myapp/R$array;
[2011-10-23 16:23:29 - myProj] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/myapp/R$array;
I have been noticing this problem when I import/use different jars for app development. I got to
Project->Properties->Java Build Path->Order & Export->
Then assign jars priorities.
And then I go for running project so I get this exception. And every time I struggle to solve this issue. I know this issue raise due to common contents of jar but ant to know reliable way to handle it.
That's why I want to know how to deal with this?
I faced this issue multiple dex files means your application have different source for same class.
To fix it i used use same jar file(android-support-v4.jar) for project and libraries also. (copied same jar file in project and library).
This issue arises not only with the android-support-v4.jar, it can arises with other libraries too. This generally comes when you import some library in your project.
To resolve this just figure out which jar is showing the multiple dex issue and make sure to have the same jar in your project and as well as in the libraries which you have imported. Doing this your problem will be resolved.
Check out all jar files added in lib folder of your project and all dependent library and remove jar if it is already added in another project or lib. This error will be only because of more than one source for same class.

Dropbox integration shows error at run time

I am integrating dropbox API with my android project,for that I downloaded android SDK from this link and also another example project from this link.While integrating both example codes in my project shows error at run time.I searched many solution in internet but unfortunately it wouldn't make my code error free.
This is my console screen
[2014-05-10 09:37:43 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/dropbox/client2/android/AuthActivity;
[2014-05-10 09:37:43 - ExampleDropboxApp] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/dropbox/client2/android/AuthActivity;
So any one please do a needful to me.
This is because the inside two Dropbox API jar files both have the class
com/dropbox/client2/android/AuthActivity.
The simple way is to remove one of them from one of jar file. You can use 7z or programs to remove them.
Here's a screen shot of the files you might need to remove in that jar file
I was facing the same problem few days back. I am mentioning below what Worked for me.
Right Click on your Project Name
Click on Build Path
Goto Configure Build Path
Goto tab Order and Export in Java Build Path
Uncheck your .jar Library.
Do let me know if this work for you :)
The ultimate solution should be to:
Open both jar files; dropbox-sync-sdk-android.jar and
dropbox-android-sdk-1.6.1.jar
Delete the client2 folder in the former sdk and replace it with
client2 from the latter
Then download a copy of json_simple-1.1.jar.
Copy json_simple-1.1.jar and dropbox-sync-sdk-android.jar into your
libs folder and include these two in your project properties; this
will help to avoid future errors
NB: You don't need to include dropbox-android-sdk-1.6.1.jar anywhere.

Play Haven SDK import

I am importing Play Haven sdk in a test project, its importing successfully but when i am trying to run my project its giving same error again and again.
13:24:12 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
[2014-03-28 13:24:12 - PrintOutApp] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
Play Have SDK link : http://help.analytics.upsight.com/api-sdk-reference/downloads/
There are 2 options:
remove android-support-v4.jar from your project [not from Haven SDK project
remove android-support-v4.jar from you project and copy it from haven sdk project
Check your project for multiple of the same file.
Use a simple file search to look for *.jar in your project files.
Some files may be named differently (I wish SDK makers would not do this) and contain the exact same libraries.
I ran into this issue myself, and it was exactly this file android-support-v4.jar. However, one of the SDK's I used renamed that file to something else. So it was a hard find.

Problems importing Android project into Eclipse / Gen-folder, libraries, Multiple dex files

So I'm trying to import a project into Eclipse. I needs some libraries, I import them, no problem. Then I import the project itself, make the reference to the libraries.
Eclipse then says:
The declared package "de.xy.ui" does not match the expected package "main.java.de.xy.ui"
I resolve this by removing the src folder from the build path (at least I think it's resolved), Eclipse doesnt show any more problems.
I try to run the project and get:
[2013-02-12 14:06:18 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v4/app/_ActionBarSherlockTrojanHorse$OnCreateOptionsMenuListener;
[2013-02-12 14:06:18 - MainActivity] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v4/app/_ActionBarSherlockTrojanHorse$OnCreateOptionsMenuListener;
I think it's because I have those libraries referenced in the project AND in the /gen folder of the project. When i delete the /gen folder it's created again when I try to run the project. The gen folder is also in the build path of the project, but removing it from there results in the same (it's added again).
What can I do?
The reason for Conversion to dalvik format failed here is that you have somehow included android-support-v4.jar more than once in your project.
Try to eliminate one copy or provide the screen shot of your Android Dependencies and libs folder.

Categories

Resources