Android – How to solve Unable to execute dex: java.nio.BufferOverflowException , Check the Eclipse log for stack trace, Conversion to Dalvik format failed
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.
Dex Loader] Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.
SearchViewDemo] Conversion to Dalvik format failed: Unable to execute dex: java.nio.BufferOverflowException.
There are four approaches to solve the conversion to Dalvik format failed error.
- Downgrading to Android SDK build tools 18.1.1
- Adding the support library.
- Fixing the issue without downgrading – (By editing the manifest file).
- 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
Windows -> Android SDK manager
Now uninstall Android SDK build tools 19
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.
Now add support library again by following these steps.
Right click on project -> Android tools -> Add support library
Updated library would be downloaded.
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 :
- Go to AndroidManifest file.
- look for “
android:targetSdkVersion"and see the value.
- Now go to “project.properties” file of your android application (This file is present in root of the android project folder).
- In “project.properties” file see the value of “target=android-<value>”.
- Now make sure both the values i.e the value in manifest file as well as the value in project file matches.
- 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.