7

我试图将Google Plus集成到我的应用程序中,并显示以下错误。下面是例外和gradlecom.android.build.transform.api.TransformException with android谷歌播放服务

错误:任务':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'' finished with non-zero exit value 1

应用的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:[email protected]' 
    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() 
    } 
} 

回答

14
  1. 尝试清洁您的项目,然后重新建设。

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

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

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

    defaultConfig { 
        multiDexEnabled true 
    } 
    
+2

搜索在谷歌开发者添加这些行..它说的应用程序的大小超过65K。我认为这是真的,因为刚刚现在与示例应用程序集成并且其工作正常 – srinu

+1

此外,这可能不是一个dex问题,根据此答案:http://stackoverflow.com/a/33026958/1174453删除构建和应用程序/ build文件夹可能会解决这个问题 - 尽管我必须排除一个无用的支持-v4 lib,这个lib-sdk在这之前就会被拉进来,这意味着65k方法的限制至少部分在这里播放。 –

+0

删除生成文件夹并删除支持库为我工作。 – Zapnologica

4

我对应用程序类中添加这

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' 

这解决了我的问题。谢谢

+0

非常感谢你兄弟.....我解决了它 –

3

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

错误是几乎相同的一个,除了Java中的OP的错误返回错误代码2.

如果最后变成了我有包含在应用程序的两个不同的模块相同的jar文件。

版本1.3.0可以在没有问题的情况下处理此问题,对于版本1.5.0,我必须用包含jar文件的单个副本的单独模块的依赖项替换jar文件。

-3

只是删除你的支持库,也将努力

0

我曾尝试与添加

multiDexEnabled true 

,但没有奏效。那么我已经将我的内部版本从23.0.2更改为

buildToolsVersion "23.0.3" 

然后它工作。希望它可以帮助你。

0

尝试在你的gradle这个

dexOptions { 
    javaMaxHeapSize "4g" 
}