Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
above is the error message while i run the simulation on genymotion
i updated all the api, actived the google+ for genymotion
i create a google map project from the default project from android studio. can anyone help me out from here?
try suggestion from google
like downgrade the dependencies, add in the multidex true and etc but it still show this error.... yes, i have added the api key also
thanks everyone but i still having error after adding all the suggestionsplease see the image below
Definitely a mutlidex issue, enable mutlidex as follows,
1. Add code
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
There should be an entry in manifest too
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
or if you have an application class then do this instead of above manifest entry
public void onCreate(Bundle arguments) {
MultiDex.install(getTargetContext());
super.onCreate(arguments);
...
}
And make sure you have clicked on sync at top right on build.gradle file, when it appears.
Clean and build.
Theory: https://developer.android.com/studio/build/multidex.html
If issue still persist give gradle file and error log.
Seems like you have gone past the ~65000 method limit. Try enabling multidex if you 're using recent versions of the Android build tools
dependencies {
compile group: 'com.android.support', name : 'multidex', version: '1.0.1'
}
In your android config
android {
defaultConfig {
// flag
multiDexEnabled true
}
}
There should be an entry in manifest or in application class(if it's there) too
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
or if you have an application class then do this instead of above manifest entry
public void onCreate(Bundle arguments) {
MultiDex.install(getTargetContext());
super.onCreate(arguments);
...
}
Edit:
You must be using build tools > 21.1.*
Related
My project run very good.
After i added google analytics, it did not allow 64k in .dex file and i have already set :
defaultConfig {
multiDexEnabled true
}
but then it have bellow error
:MainEntry:transformClassesWithMultidexlistForDebug FAILED
Error:Execution failed for task ':MainEntry:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't read [C:\Users\temp2\android-git\MainEntry\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar] (Can't process class [com/vtcpay/a/a.class] (Unknown verification type [143] in stack map frame))
be sure enabled multidex output, as shown in the following code snippet:
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
make sure you added in your manifest the MultiDexApplication class from the multidex support library to the application element
...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
for more detailes you can see Configure Apps with Over 64K Methods
Thanks you everybody
I have already found solution for this issue. i should add this script bellow default config.
A multidex configuration requires significantly increased build processing time because the build system must make complex decisions about what classes must be included in the primary DEX file and what classes can be included in secondary DEX files. This means that routine builds performed as part of the development process with multidex typically take longer and can potentially slow your development process.
productFlavors {
// Define separate dev and prod product flavors.
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion 14
}
}
I'm relatively new to Android programming and I am trying to create a Google Maps project. I used the template option in Android Studio, and I added the key for the API.
I haven't added any of my own code and left the template code as is because I just wanted to run the code and see what it looks like, however, I keep getting a multi dex error when I try to run this on the emulator causing the build to fail. It's weird to me that I am getting this error because I haven't added ANY code at all and am using what the Google Maps template has from Android Studio.
Anyone know why this error shows up on a brand new project? The error I see is pasted below.
Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_91\bin\java.exe'' finished with non-zero exit value 2
as quoted below:
Your probably compiling all of the play-services API's using compile 'com.google.android.gms:play-services:9.2.0'... Now we can selectively compile API's to avoid dex limit of 64K. For Google Maps use com.google.android.gms:play-services-maps:9.2.0... – Loki Jul 1 at 19:01
Answer from Loki worked and was very simple to do.
setting up google play services
Go through this link just add the dependencies which you want in your application.
This will prevent 64k exceeding error.
Happy coding.
For those who tried all the above methods and failed. Try changing the mini sdk version to 21 in the build.gradile file. For me it was on 16 and when I changed it to 21 the multidex error was gone for good.
minSdkVersion 21
The issue is you currently have a high number of methods. There can only be 65536 methods for dex. You can try enabling multiDex by editing your build.gradle file.
android {
//stuff
defaultConfig {
...
// Enable multiDex support.
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Also, oops as the poster above mentioned in your manifest you also need to add that you are using the multidex class from the multidex support library.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.dexapp">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
Change your Gradle build configuration to enable multidex
android {
compileSdkVersion 23
buildToolsVersion "24.0.0 rc2"
defaultConfig {
applicationId "com.try.app"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
In your manifest add the MultiDexApplication class from the multidex support library to the application element.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Note: Visit https://developer.android.com/studio/build/multidex.html for more info.
Set property multiDexEnabled to true in defaultConfig. This error occurs when method references increase the limit of 65k. Check Google Play Service APIs.
android{
...
defaultConfig {
...
multiDexEnabled true
}
...
}
Here is a good source to get started with Google Maps Android API
I removed the dependencies as suggested by Loki and it works.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.google.android.gms:play-services-maps:9.4.0'
}
What code must i add and where to get 64K methods?
I try and build signed APK but it give me issue whole time!
Error:The number of method references in a .dex file cannot exceed 64K.
Error:Execution failed for task
’:myapp:transformClassesWithDexForRelease’. >
com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException:
java.lang.UnsupportedOperationException
KUMAR's answer is pretty close but not covering all the details.
Firstly add necessary configuration to your build.gradle of app module:
app/build.gradle
android {
defaultConfig {
multiDexEnabled true
}
}
dependencies
{
compile 'com.android.support:multidex:1.0.1'
}
In the second step you can follow two paths depending on your need.
a. You don't have a custom application class. So you need to add the MultiDexApplication class from the multidex support library to the application element in your manifest:
AndroidManifest.xml
<application
android:name="android.support.multidex.MultiDexApplication"
OR
b. You have a custom application class. So you need to make it extend MultiDexApplication class:
MyApplication.java
public class MyApplication extends MultiDexApplication {
}
AndroidManifest.xml
<application
android:name="MyApplication"
You should be ready to go over 64K method limit.
You can read this tutorial over multidex to understand the logic behind all of these.
If our application is exceeding more than 64K methods then we need to enable the multiDex in our code.
Add the dependency in build.gradle
dependencies
{
compile 'com.android.support:multidex:1.0.0'
}
Enable multidex in build.gradle like the following
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
Now sync your code and run it then it will work.
I've developed an android application in Eclipse which uses lot of library JAR files so i got exception of
Unable to execute dex: method ID not in [0, 0xffff]: 65536
So i thought to implement multidex. I searched many blogs but nothing helps me in the eclipse framework. So i installed the Gradle plugin for eclipse to achive the multidex which was mentioned in many posts (As mentioned here, and Here). Both telling the same method to add
multiDexEnabled true
but its not working
I asked my application class to override
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
and in the gradle file which is builded i edited as
android{
defaultConfig {
minSdkVersion 14 //lower than 14 doesn't support multidex
targetSdkVersion 22
// Enabling multidex support.
multiDexEnabled true
}
}
But it doesn't helped me. Can anyone help me to find how to multidex my application with eclipse or correct way to multidex with the gradle.
add this to your gradle dependencies:
dependencies {
compile 'com.android.support:multidex:1.0.0'
...
}
If that doesn't work, I'm lost as to how to help you because that is the only thing missing that I can see from other answers here on SO.
You need to do 3 things to enable MultiDex:
1) Add following dependency to your build.gradle file:
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
2) Enable multidex in your build.gradle file:
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
3) Finally, if you are using a custom Application class, it should extend MultiDexApplication:
public class MuyApplication extends MultiDexApplication {
}
or if you are not using a custom Application class, do the following in your manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
I have multiple libraries in my libs folder in android. When I try to add "Tapjoy", I get the error:
unable to execute dex method id not in 0 0xffff 65536 android problem
is coming
and, when I am trying to configure build path and adding external jars,
java.lang.NoClassDefFoundError: com.tapjoy.TapjoyConnect
I'm stuck on this problem. Can any one give me solution?
Congratulation you have reached the 65K method limit you have two options :
a) Clean up some code by removing unnecessary libraries / using ProGuard.
b) Multidex solution , follow these steps
Make sure your Android SDK Build and Android Support Repository are updated to latest version.
Modify your build.gradle by adding the support dex lib and enabling the multidex
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Modify your manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
p.s if you already extend Application then just override the attachBaseContext method
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
for more info:
Building Apps with Over 65K Methods