【问题标题】:Getting Transform Exception while building the project [duplicate]构建项目时出现转换异常[重复]
【发布时间】:2016-02-04 13:03:20
【问题描述】:

当我尝试运行我的应用程序时出现以下错误:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 3

这是我的应用级别build.gradle

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}


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

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    defaultConfig {
        applicationId 'com.galleri5.android'
        multiDexEnabled true
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 9
        versionName "0.8.1"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()
    mavenLocal()
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
    maven { url "https://jitpack.io" }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:support-v4:23.1.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:design:23.1.0'
    compile 'com.facebook.android:facebook-android-sdk:4.3.0'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
    compile 'com.android.support:recyclerview-v7:23.1.0'
    compile 'com.android.support:cardview-v7:23.1.0'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.github.clans:fab:1.6.1'
    compile 'com.facebook.fresco:fresco:0.8.0+'
    compile 'com.facebook.fresco:imagepipeline-okhttp:0.8.0+'
    compile 'uk.co.chrisjenx:calligraphy:2.1.0'
    compile 'com.google.android.gms:play-services-analytics:8.1.0'
    compile 'com.commit451:PhotoView:1.2.4'
    compile 'com.github.liuguangqiang.swipeback:library:1.0.2@aar'
    compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
        transitive = true;
    }
}

这是我的项目级别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()
    }
}

为什么会出现此错误以及如何解决?

【问题讨论】:

  • 实际上OP的错误与标记为重复的错误不同。问题中的错误表明它以错误值3退出!
  • 清理项目 -> 重启 android studio -> 清理项目 :)

标签: android android-gradle-plugin android-build


【解决方案1】:

启用multidex,它为我解决了问题。

defaultConfig {
multiDexEnabled true
}

如有任何疑问,请随时提出。

【讨论】:

  • 我已经将 multiDexEnabled 设为 true。无论如何,我清理了项目然后运行它,它现在可以工作了。
  • 我有同样的问题我应用以下代码来解决问题 javaMaxHeapSize "4g"
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-07-16
  • 2016-10-22
  • 2018-11-21
  • 1970-01-01
  • 2014-04-08
  • 1970-01-01
  • 2022-07-07
相关资源
最近更新 更多