【问题标题】:I m getting this error ..pls guide me to solve it我收到此错误..请指导我解决它
【发布时间】:2016-04-18 05:56:48
【问题描述】:

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

com.android.build.api.transform.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'' 以非零退出值结束 3**

**我的腰带文件**

apply plugin: 'com.android.application'

 android {
  compileSdkVersion 23
  buildToolsVersion "23.0.2"

 defaultConfig {
    applicationId "com.app"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 16
    versionName "1.16"
    multiDexEnabled true
 }
 buildTypes {
    release {
        minifyEnabled false
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
 }

 compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
 }

 packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
  }
 }

 dependencies {
  compile fileTree(include: ['*.jar'], dir: 'libs')
  testCompile 'junit:junit:4.12'
  compile 'com.facebook.android:facebook-android-sdk:4.+'
  compile 'com.google.android.gms:play-services:8.4.0'
  compile 'com.google.android.gms:play-services-appinvite:8.4.0'
  compile 'com.google.android.gms:play-services-analytics:8.4.0'
  compile 'org.apache.httpcomponents:httpclient:4.5.1'
  compile 'com.android.support:multidex:1.0.0'
  compile 'com.android.support:support-v13:23.1.1'
  compile 'com.android.support:design:23.1.1'
  compile 'com.google.android.gms:play-services-ads:8.4.0'
  compile 'com.google.android.gms:play-services-identity:8.4.0'
  compile 'com.google.android.gms:play-services-gcm:8.4.0'
  compile 'com.android.support:support-v4:23.1.1'
  compile 'com.jayway.android.robotium:robotium-solo:5.5.4'
 }

【问题讨论】:

  • 在 android tag dexOptions { javaMaxHeapSize "4g" } 中添加这个并尝试一次。
  • rebuild 你的项目并运行。
  • 我的answer 解决了您的问题吗?
  • 设置minifyEnabled true.
  • 您的依赖项太多,超出了 JVM 内存。如果您已单独包含其他播放服务包,为什么还要有 compile 'com.google.android.gms:play-services:8.4.0'

标签: java android android-gradle-plugin


【解决方案1】:

1) 首先,尝试清理并重新启动您的项目。在大多数情况下,这将解决问题。

2) 如果问题仍然存在:

导入multidex依赖:

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

在您的清单中添加 MultiDexApplication 类:

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

如果您的应用已经扩展了Application 类,您可以重写attachBaseContext() 方法并调用MultiDex.install(this) 以启用multidex

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

最后,通过添加multiDexEnabled true 来更新您的build.gradle

defaultConfig {  
        ...
        multiDexEnabled true  
    }  

【讨论】:

  • @AmitEkbote,从依赖项中删除这个 compile 'com.google.android.gms:play-services:8.4.0 并重新编译。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-19
  • 2021-06-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多