【问题标题】:com.android.build.transform.api.TransformException with android google play servicescom.android.build.transform.api.TransformException 与 android 谷歌播放服务
【发布时间】:2016-01-05 13:46:22
【问题描述】:

我正在尝试将 Google Plus 集成到我的应用程序中,但它显示以下错误。下面是异常和gradle

错误:任务 ':app:transformClassesWithDexForDebug' 执行失败。

com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1 .7.0_79\bin\java.exe'' 以非零退出值 1 结束

app build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "xxx.com.xxxx"
        multiDexEnabled true
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
    //depend-materialcalendar
    compile 'com.prolificinteractive:material-calendarview:0.8.1'
    compile 'com.android.support:gridlayout-v7:23.0.1'
    compile 'com.android.support:cardview-v7:23.0.1'
    compile 'com.melnykov:floatingactionbutton:1.3.0'
    //depend-cometchat
    compile 'com.yalantis:contextmenu:1.0.4'
    compile 'com.google.code.gson:gson:2.3'
    compile files('libs/appcompat_v7.jar')
    compile files('libs/cometchat-sdk.jar')
    compile files('libs/jsoup-1.7.3.jar')
    compile files('libs/picasso-2.5.2.jar')
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.google.android.gms:play-services-base:8.1.0'
    compile 'com.google.android.gms:play-services-maps:8.1.0'
    compile files('libs/volley.jar')
    compile files('libs/PayPalAndroidSDK.jar')
    compile files('libs/gcm.jar')
    compile 'com.soundcloud.android:android-crop:1.0.1@aar'
    compile 'com.facebook.android:facebook-android-sdk:4.6.0'
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.google.android.gms:play-services-plus:8.1.0'
    compile 'com.google.android.gms:play-services-identity:8.1.0'

}

项目 build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
        classpath 'com.google.gms:google-services:1.4.0-beta3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

【问题讨论】:

    标签: android android-studio google-plus google-play-services build.gradle


    【解决方案1】:
    1. 尝试清理您的项目,然后重新构建。

    2. 尝试在您的应用程序build.gradle 文件中添加multiDexEnabled true。

      defaultConfig {
          multiDexEnabled true
      }
      

    【讨论】:

    • 在谷歌开发者上搜索..它说应用程序大小超过 65k。我认为这是真的,因为刚刚与示例应用程序集成并且它的工作正常
    • 另外,这可能不是 dex 问题,根据这个答案:stackoverflow.com/a/33026958/1174453 删除 build 和 app/build 文件夹也可以解决这个问题 - 尽管我确实必须排除无关的支持 -在此之前与 facebook-sdk 一起使用的 v4 库,这意味着 65k 方法限制至少部分在这里起作用。
    • 删除构建文件夹和删除支持库对我有用。
    【解决方案2】:

    我已经在 Application 类中添加了这个:

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

    在我的应用程序 build.grade 文件中:

     defaultConfig {
        applicationId "com.example.android.exampleapp"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    
    }
    

    并将其添加为依赖项:

         compile 'com.android.support:multidex:1.0.0'
    

    这解决了我的问题。谢谢

    【讨论】:

      【解决方案3】:

      当我将 Android Gradle 插件版本从 1.3.0 移动到 1.5.0 时,我在当前项目中遇到了同样的问题。

      除了java返回错误代码2之外,该错误与OP的错误几乎相同。

      如果最终发现我在应用程序的两个不同模块中包含相同的 jar 文件。

      版本 1.3.0 可以毫无问题地处理这个问题,对于版本 1.5.0,我必须将 jar 文件替换为包含单个 jar 文件副本的单独模块的依赖项。

      【讨论】:

        【解决方案4】:

        我尝试过添加

           multiDexEnabled true
        

        但是没有用。然后我将构建版本从 23.0.2 更改为

          buildToolsVersion "23.0.3"
        

        然后就可以了。希望对你有帮助。

        【讨论】:

          【解决方案5】:

          尝试在你的 gradle 中添加这些行

          dexOptions {
              javaMaxHeapSize "4g"
          }
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2014-08-18
            • 2014-05-23
            • 1970-01-01
            • 1970-01-01
            • 2013-09-17
            • 1970-01-01
            相关资源
            最近更新 更多