Android project: Conversion to Dalvik format failed with error 1 - java

I am writing an android application using eclipse and am trying to use jar files I generated from another eclipse (not android) project I wrote. However, when I try to run my android application, I get the following error message:
[2014-05-15 18:42:25 - ResearchNotebook] Dx 1 error; aborting
[2014-05-15 18:42:25 - ResearchNotebook] Conversion to Dalvik format failed with error 1
which is preceeded by a longer error message.
I looked at the following question (Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library), and but am not sure how I would reconfigure the eclipse IDE so that rt.jar and android.jar are not being passed to dx.
However, I wrote non android java code within the same project using the jar and ran it in the console. It worked perfectly fine. The problem only arises when I try to use the jar for the classes pertaining to the android application.
At this point, I have tried many different alternatives, including cleaning the project, deleting the jars from the buildpath and adding them again, and changing order and export according to the following site: http://tools.android.com/recent/dealingwithdependenciesinandroidprojects.
Is there something else I should have done when generating the jar from my eclipse (non android) project? I have really hit a wall this problem and am at a loss about how to proceed.

Try the following:
Uncheck "Build Automatically" from the "Project" menu.
Do a project cleanup.
Export your project
Hope it helps.

Related

Conversion to Dalvik format failed with error 1 while compiling jitsi project

I am trying to compile and run the project
https://github.com/jitsi/jitsi-android on Eclipse by Importing.
I have imported the project successfully,Added External Jar files and Fix some of compilation errors.
When I try to run app, It is giving
Conversion to Dalvik format failed with error 1 Error on the console.So that I Clean the project, checked the all the jar files from Order and Export tab and build it again.
but it doesn't work for me.
Finally, I unchecked the all the libraries from Order and Export tab,build and run it again.
But still its giving me same error and my application is getting crashed every time i run it.
Any help will be appreciated , i really want to run this application.
here is my libs folder screenshot:-
I've had the same problem once.
Here is what I found out when I was trying to solve my issue:
The error is caused when there are two Classes/Packages with the same name (For example when LibaryX has Class org.a.b.c.Sample and LibaryY has class org.a.b.c.Sample aswell)
Different approaches which worked for some people (So if you have the error yourself, make sure to test following things out):
A) Two Libaries have the exactly same package/class-> Delete the class in one of the Libaries
B) One Jar is detected twice because it's for example in the project source folder and in the Java Build Path Libaries aswell
C) Updating Proguard often fixes it aswell (Put the new Proguard jars in [Android SDK folder]\tools\proguard\lib)
D) Cleaning the Project also helped many people (you already did that, so that won't be your solution)
When I had this issue myself it was caused because I did not follow the instructions of one of the libaries that I used. After following the libary instructions step by step, everything worked fine again.
Greetings
Felix

Conversion to Dalvik format failed error from Eclipse when compiling on Ubuntu [duplicate]

This question already has answers here:
Unable to execute dex: Multiple dex files define Lcom/myapp/R$array;
(54 answers)
Closed 8 years ago.
Is it my code or is running Eclipse on Ubuntu linux (or any other distro variant) causing this error message to show very often? Either when trying to compile, build project, or an equivalent, the error comes from the IDE itself. I read many questions in here that asking about maybe the same case that I have, like if the error message shows up you need to restart Eclipse and the error won't appear again.
Now I have one project thats using #override code like OnCreate, OnPause, OnStop and others on my script MainActivity.java. There is nothing wrong with the code, but everytime I try to run it as an android application, Eclipse shows an error like this:
Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/annotation/AnimRes;
Why is that? Has anyone had the same problem and discovered the answer? Many thanks.
Regards,
Indra.
This is due to multiple occurrences of the same jar file getting added to your project. Generally, it is very difficult to find out multiple occurrences.
It would be better to remove the classpath of all the reference Android projects which our project is referring, and add them from the scratch.
Follow this procedure:
Build the Android libraries first and make sure the jars required for building the Android projects are not exported
Add the Android libraries in the project.properties of the Android project
Compile the required project
When a compilation issue comes, add the required jar
Don't forget to export the jar
I think it is related to the fact that there may be 2 jar files containing the same content. Check your build path and library projects and if you see same thing referenced twice remove it from one place.
I think you have to clean your project and rebuild it. because The temp values might have been available. When you clean it, this app will work and you can take build now

What is app.lib and how do I import it into an Android project?

I'm an iOS developer trying to build an existing Android app on a Mac - yikes! I'm sure this is a simple question: I've got the project loaded in Eclipse, but it won't build due to the error:
"Missing required Java project: 'app.lib'"
Is this a standard Java library? Eclipse nicely displays a wizard to attempt to fix the problem by bringing up the Configure Build Path dialog - but where app.lib is listed as 'missing' -
Where do I get this library?
As far as I know, app.lib is not a standard Java/Android library.
Clean and rebuild your project
Close it and reopen it
Try to remove it on your build path and see if you can build your project without it.

Conversion to Dalvik format failed. Issue repeats each time Eclipse is opened

This problem happens each time I close and reopen Eclipse. It started about a week or so ago. I have not updated Eclipse or the SDKs before this happened.(Not recently)
[2013-12-02 19:06:53 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
[2013-12-02 19:06:53 - com.engel.BillFold] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
The jar "android-support-v4" is being added into my build configuration. It is already in the Private Library that is generated during the build (If android-support-v4 is present.)
I can correct the problem by removing Android 4.3 Library, Private Library (containing android-support-v4) and the intruding extra android-support-v4 jar. Then add Android 4.3 Library and android-support-v4 back in. Reorganize and check off to activate. Clean. Everything will work fine as long as I do not close and restart Eclipse.
One other thing that started about the same time, the debug controls (Disconnect, Terminate, and Suspend) are lit up as if an app is running in debug mode. If you click on Disconnect, I just get an information dialog saying that "The chosen operation is not enabled". Just mentioning this part since there may be some connection.
I have read every post I can find on this subject (love SO). I was using the Eclipse bundle from Feb 2013 as downloaded from Android Dev. I just updated to the latest yesterday(Build: v22.3.0-887826), but the problem remains.
One more thought. This started the same day I setup an alarmmanager section in my app. The WakefulBroadcastReceiver is focused on if I do not remove the libraries and extra jar, then replace the offending jars. If I simply remove the extra jar(support-v4) the an error is shown on the WakefulBroadcastReceiver.
The import android.support.v4.content.WakefulBroadcastReceiver cannot be resolved
Any ideas?
UPDATE
Ok. So I tried just removing the Android Private Libraries in the build path. This will allow me to send the app to my device. It works fine. Till I close Eclipse and restart it. Then the Private Library is back. Keep in mind that the android-support-v4 is still out in the open, but on restart it is put back into a library by Eclipse. This gives me two of the same jar files. Deleting the exposed jar has no effect. Deleting the Library temporarily fixes the issue.
Damn computers.
Any insight would be appreciated.
Try this:
Go to Project/Properties/Java Build Path/Order and Export -- Make sure there's a check in front of Android Dependencies and the support library, if you use it.Mark all checkboxes.Click on Apply and clean the project.
Hope this helps.

Idea + Play Framework - cannot resolve method/symbol

I use IntelliJ IDEA 12, Play 2.2.0, I have Scala plugin installed, Play 2.0 support plugin installed.
I created java play application via termina (play new). Andas you can see in this pictures I always get this error: "cannot resolve method ok()" or "cannot resolve symbol at"
http://sluchatka.kvalitne.cz/pics/1.png
http://sluchatka.kvalitne.cz/pics/2.png
I searched the web for this problem the whole day, but I didn't find solution.
Can you please help me?
The first problem (unable to resolve reference to template) is because your template probably has not been compiled by the moment (and thus IDEA does not see compiled template and can't resolve reference to it).
I usually develop Play apps having ~run command launched in Play console. So that any changes to templates are immediately compiled and changes detected by IDEA.
As for the second one it seems like a deficiency in Play IDEA plugin. It does not work seamlessly within templates I should say. Lots of glitches. The best way I found is to have ~run launched so that small problems are detected immediately.
According to intelliJ support it is better to import the command line created play 2 project using the IDE import project wizard instead.
File -> Import Project
Select play2 project location
Import as SBT project
This was due to the "play idea" command being outdated or not fully compatible with the current play 2 and scala plugins for intelliJ.
A bonus is that errors start to appear properly, we had trouble with that earlier.
I was having a similar issue with Play 2.4.2 and Intellij 14.1.4. I could run the basic "play-java" example/starter app in Intellij, even though the editor showed errors like "cannot resolve method ok()".
Here's what solves the problem for me:
Before starting, make sure your project is not open in Intellij.
Delete the ".idea" folder from your existing app, OR just create a new app using "activator new".
On the command line, cd to the app's folder and compile using "activator compile".
In Intellij, File -> Open, and select your app's folder. For the SBT import options, I left the boxes unchecked (e.g. "Use auto-import", "Create directories for empty content roots automatically", etc.) but I don't think it matters.
Once everything finishes loading, you shouldn't see the errors any more.
This click in the Project Structure is your answer.

Categories

Resources