If you have recently added any Android library project or upgraded to a newer version of  Android SDK build tools and you have got an  unable to execute error then this post is for you. You might have got this error even if you are trying to import an existing Android project or if you are working with android library. For example google play services.

There are four approaches to solve the conversion to Dalvik format failed error.

  1. Downgrading to Android SDK build tools 18.1.1
  2. Adding the support library.
  3. Fixing the issue without downgrading – (By editing the manifest file).
  4. By adding one more line to “project.properties” file – (which is present in root folder of your project).

Now its up to you, how you want to fix the project.

Downloading Android SDK build tools 18.1.1

In eclipse, go to

Now uninstall Android SDK build tools 19

solve_error1

Now Install Android SDK build tools 18.1.1

After successful installation, restart eclipse and now error will be fixed.

If you want to solve the “Conversion to Dalvik format error” without uninstalling android SDK tools, then you need to add(update) the support library.

 

Adding the support library.

Right click on your project and go to “libs” folder. Delete the android-support-v4 file from the project.

 solve-java.nio.BufferOverflowException

 

Now add support library again by following these steps.

Updated library would be downloaded.

solve_error3

 

Now clean your project.

If error still occurs then delete all projects from project explorer and workspace. And create a new project and delete the support library and add it again by following the above steps.  Now conversion to Dalvik will not fail.

Now the last approach which would work with all versions to solve Unable to execute dex: java.nio.BufferOverflowException, Conversion to Dalvik format failed.

Third approach is without Downgrading – By editing manifest file

Steps involved are :

  1. Go to AndroidManifest file.
  2. look for “android:targetSdkVersion" and see the value.
  3. Now go to “project.properties” file of your android application (This file is present in root of the android project folder).
  4. In “project.properties” file see the value of  “target=android-<value>”.
  5. Now make sure both the values i.e the value in manifest file as well as the value in project file matches.
  6. If they are not matching then make them same.(either copy the manifest value to project.properties or copy the value from project.properties to manifest ).

 

Fourth Approach – By adding one more line in project.properties file

In the end of your project.properties file add one more line “sdk.build.tools=targetSdkVersion”

This “targetSdkVersion” value is present in your AndroidManifest file. I have used 18.1.1 because my sdk build tools value in android manifest file is 18.1.1. Change the value according to your manifest file i.e target Sdk Version with which you are developing application.

 

If you still have any error then feel free to share. If you have any suggestions, please feel free to tell me. And please let me know which among the above 4 methods have solved you error so that it would help others.