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

时间:2017-04-06 06:19:58

标签: android android-studio build.gradle

我在android studio的android项目中工作过,当我开始运行gradle build并显示以下错误时。有人帮我解决了什么问题

  

错误:任务':app:transformClassesWithDexForDebug'执行失败。   com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:Process' command' / Library / Java / JavaVirtualMachines /jdk1.8.0_65.jdk/Contents/Home/bin/java''完成非零退出值3

的build.gradle

   apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.stage.lookara"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled = true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
    }
    }

    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile files('libs/twitter4j-core-4.0.4.jar')
    compile files('libs/slider.jar')
    compile 'com.google.android.gms:play-services:8.3.0'
    compile 'com.facebook.android:facebook-android-sdk:4.0.0'
    compile 'com.etsy.android.grid:library:1.0.5'
    compile 'com.baoyz.swipemenulistview:library:1.3.0'
    compile files('libs/universal-image-loader-1.9.5.jar')
    compile 'com.github.darsh2:MultipleImageSelect:v0.0.3'
    compile files('libs/pherialize-1.2.1.jar')
    compile 'com.wang.avi:library:2.1.3'
    compile 'com.mikhaellopez:circularprogressbar:1.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 
    'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
    compile 'com.felipecsl:gifimageview:2.1.0'
    }

    repositories {
    jcenter()
    }

    dependencies {
    compile 'org.adw.library:discrete-seekbar:1.0.1'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.+'
    compile 'org.jsoup:jsoup:1.7.3'
    }

2 个答案:

答案 0 :(得分:1)

您正在编辑整个Google Play服务库:

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

在编译期间可以越过64K reference limit'

请参阅this

如果你只是使用库中的某些服务,你可以Selectively compiling APIs into your executable

像:

 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'

我还建议使用最新版本的播放服务compile 'com.google.android.gms:play-services:10.2.1'

第二路

如果您真的想要使用整个库:在您的应用程序中启用Multidex

你的Gradle中的

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

dependencies {
  compile 'com.android.support:multidex:1.0.1'
}
应用程序类中的

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

在清单中定义应用程序类:

    <?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>

答案 1 :(得分:0)

先尝试清洁。

如果不起作用,请将multiDexEnabled添加到build.gradle文件中。

defaultConfig {
    multiDexEnabled true
}

请参阅:com.android.build.transform.api.TransformException