com.android.build.transform.api.TransformException

后端 未结 25 2031
独厮守ぢ
独厮守ぢ 2020-11-22 06:14

I am trying to integrate Google sign in, in my app, I added these libraries:

compile \'com.google.android.gms:play-services-identity:8.1.0\'
compile \'com.go         


        
相关标签:
25条回答
  • 2020-11-22 06:50

    you can see the documentation of Android

    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'
    }
    

    Manifest.xml

    <?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>
    
    0 讨论(0)
  • 2020-11-22 06:51

    At my case change buildToolsVersion from "24" to "23.0.2", solve the problem.

    0 讨论(0)
  • 2020-11-22 06:52

    Simply go to Build - Edit Build Types - Properties Tab - Build Type Version and downgrade it to ver 23.0.1. Click ok. This works for android studio 1.5. It worked for me.

    0 讨论(0)
  • 2020-11-22 06:53

    Another thing to watch for, is that you don't use

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

    That will import ALL the play services, and it'll only take little more than a hello world to exceed the 65535 method limit of a single dex APK.

    Always specify only the services you need, for instance:

    compile 'com.google.android.gms:play-services-identity:8.3.0'
    compile 'com.google.android.gms:play-services-plus:8.3.0'
    compile 'com.google.android.gms:play-services-gcm:8.3.0'
    
    0 讨论(0)
  • 2020-11-22 06:54

    A helpful answer if all above didn't work for you.

    Go to your app gradle file,

    Check all the dependency versions are mentioned with proper version code rather than any relative value like (com.example.demo:+)

    Previous - implementation 'com.google.api-client:google-api-client-android:+'

    After - implementation 'com.google.api-client:google-api-client-android:1.30.0'

    0 讨论(0)
  • 2020-11-22 06:55

    I resolved it with the next:

    I configured multidex

    In build.gradle you need to add the next one.

    android {
    ...
       defaultConfig {
           ...
           // Enabling multidex support.
           multiDexEnabled true
           ...
       }
       dexOptions {
          incremental true
          maxProcessCount 4 // this is the default value
          javaMaxHeapSize "2g"
       }
    ...
    }
    dependencies {
    ...
       compile 'com.android.support:multidex:1.0.1'
    ...
    }
    

    Add the next one in local.properties

    org.gradle.parallel=true
    org.gradle.configureondemand=true
    org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
    

    After that into Application class you need to add the Multidex too.

     public class MyApplication extends MultiDexApplication {
    
       @Override
       public void onCreate() {
           super.onCreate();
           //mas codigo
       }
    
       @Override
       protected void attachBaseContext(Context base) {
           super.attachBaseContext(base);
           MultiDex.install(this);
       }
    }
    

    Don't forget add the line code into Manifest.xml

    <application
        ...
        android:name=".MyApplication"
        ...
    />
    

    That's it with this was enough for resolve the bug: Execution failed for task ':app:transformClassesWithDexForDebug. Check very well into build.gradle with javaMaxHeapSize "2g" and the local.properties org.gradle.jvmargs=-Xmx2048m are of 2 gigabyte.

    0 讨论(0)
提交回复
热议问题