Execution Failed for Task ':App:Transformclasseswithdexfordebug' While Implementing Google Sign in for Android

I get: Error:Execution failed for task ':app:transformClassesWithDexForDebug'. when making Google maps App

clean and see still error is there if yes,

1.go to your build.gradle file.
add multiDexEnabled true

 defaultConfig {
multiDexEnabled true
}

2.in your dependencies add compile 'com.android.support:multidex:1.0.1'

dependencies {
compile 'com.android.support:multidex:1.0.1'
}

3.inside your application tag in menifest add android:name="android.support.multidex.MultiDexApplication"

<application
android:name="android.support.multidex.MultiDexApplication"
....

4.use this override method on your launching activity

 @Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}

Android Error:Execution failed for task ':app:transformClassesWithDexForDebug'

You are compiling the whole Google play services library:

compile 'com.google.android.gms:play-services:8.3.0'

which can cross the 64K reference limit' during compiling..

See this

if u just use some services from the library you can Selectively compiling APIs into your executable

Like:

 compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.android.gms:play-services-plus:8.3.0'
compile 'com.google.android.gms:play-services-location:8.3.0'

I would also suggest to use latest version of play services compile 'com.google.android.gms:play-services:10.2.1'

2nd Way

If you really want to use the whole library : Enable Multidex in your application.

in your Gradle:

    android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 25
multiDexEnabled true
}
...
}

dependencies {
compile 'com.android.support:multidex:1.0.1'
}

in Application class:

 public class MyApplication extends SomeOtherApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}

Define the application class in manifest:

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.ide.common.process.ProcessException:

At last finally i solved my problem, thank you for your support.This is my Gradle file.

build.gradle(Module:App)

buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}

dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

repositories {
maven { url 'https://maven.fabric.io/public' }
}

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.whyz.kitetech.mobile.cdrapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {

debug {
debuggable = true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
compile('com.digits.sdk.android:digits:1.9.4@aar') {
transitive = true;
}

compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.firebaseui:firebase-ui:0.3.1'
compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'com.firebase:firebase-client-android:2.5.0'
compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.android.support:multidex:1.0.0'
compile 'org.apache.commons:commons-io:1.3.2'
}

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException:..non-zero exit value 3

I just update my gradle file like below.This work like charm!!

I added below code in my gradle:

dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
preDexLibraries = false //delete the already predexed libraries
}

My updated Gradle:

    apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.myapplicationname.app"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
//====================Add below two line=============
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
preDexLibraries = false //delete the already predexed libraries
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
useLibrary 'org.apache.http.legacy'

}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile files('libs/gcm.jar')
compile 'com.android.support:multidex:1.0.1'
compile 'org.apache.httpcomponents:httpcore:4.4.4'
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: "httpclient"
}
//facebook sdk
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'org.apache.httpcomponents:httpcore:4.4.3'

compile 'com.paypal.sdk:paypal-android-sdk:2.12.4'
//facebook sdk
compile 'com.facebook.android:facebook-android-sdk:4.7.0'

}


Related Topics



Leave a reply



Submit