Gradle重复条目:构建失败

时间:2016-01-06 02:38:34

标签: java android google-app-engine gradle

我几乎每次向我的应用添加新模块时都遇到此问题,但这次我根本无法解决它。我厌倦了不友好的信息和gradle工具。有人请求帮助:如果你需要依赖关系输出也让我知道 - 它很大:(

Error:
:app:transformClassesWithJarMergingForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
  

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com / google / appengine / tools / appstats / Inter   nalProtos $ 1.class

以下是4个gradle文件:

顶级gradle:

buildscript {
repositories {
    jcenter()
    mavenCentral()

}
dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
    classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
    classpath 'com.google.gms:google-services:1.5.0-beta2'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    jcenter()
    mavenCentral()

   }
}

App gradle:

apply plugin: 'com.android.application'
apply plugin: 'hugo'


android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

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

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

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

}
apply plugin: 'com.google.gms.google-services'

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/nineoldandroids-2.4.0.jar')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:gridlayout-v7:23.1.1'
compile 'com.android.support:mediarouter-v7:23.1.1'
compile 'com.android.support:palette-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'

compile 'com.android.support:support-v13:23.1.1'

compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.mikhaellopez:circularimageview:2.1.1'
compile 'com.cocosw:bottomsheet:0.+@aar'
compile 'com.github.bumptech.glide:okhttp-integration:1.3.1'

compile 'com.google.android.gms:play-services-auth:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile project(path: ':backend', configuration: 'android-endpoints')


compile project(path: ':commons')
}

后端gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.appengine:gradle-appengine-plugin:1.9.18'
    }
}

repositories {
    jcenter();
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.18'
    compile 'com.google.appengine:appengine-endpoints:1.9.18'
    compile 'com.google.appengine:appengine-endpoints-deps:1.9.18'
    compile 'javax.servlet:servlet-api:2.5'
    compile 'com.ganyo:gcm-server:1.0.2'

    compile project(path: ':commons')
}

appengine {
  downloadSdk = true
  appcfg {
    oauth2 = true
  }
  endpoints {
    getClientLibsOnBuild = true
    getDiscoveryDocsOnBuild = true
  }
}

Commons gradle:

apply plugin: 'java'

dependencies {

    compile 'com.googlecode.objectify:objectify:4.0b3'
    compile 'com.google.code.gson:gson:2.5'
}

3 个答案:

答案 0 :(得分:1)

你可以这样尝试

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

它可能对你有帮助。

答案 1 :(得分:0)

你可以在

下试试

android {

packagingOptions {         排除'META-INF / DEPENDENCIES'         排除'META-INF / NOTICE'         排除'META-INF / LICENSE'         排除'META-INF / LICENSE.txt'         排除'META-INF / NOTICE.txt'     } }

可能会帮到你

答案 2 :(得分:0)

我删除了编译项目(路径:':commons')并且一切正常。但我不得不在app和后备中加入相同的POJO。把它们放在一起搞乱了。可能有更好的方法在app和后端之间共享课程。