运行项目时 Android Gradle 构建错误

标签 android

我在下面提到了我的 gradle,请让我知道该问题的解决方案是什么,并在我的项目中使用了 api 级别 25

apply plugin: 'com.android.application'
apply plugin: 'realm-android'

android {
    signingConfigs {
        config {
            keyAlias 'yaksha'
            keyPassword '123456'
            storeFile file('/home/abhinav/Downloads/yaksha.jks')
            storePassword '123456'
        }
    }
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.tene.yaksha"
        minSdkVersion 17
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testApplicationId "com.tene.yaksha1"
        testInstrumentationRunner "android.test.InstrumentationTestRunner"
        testHandleProfiling true
        testFunctionalTest true

    }
    testOptions {
        reportDir "$rootDir/test-reports"
        resultsDir "$rootDir/test-results"
    }

    dataBinding {
        enabled = true
    }
    dexOptions {
        //incremental = true;
        preDexLibraries = false
        javaMaxHeapSize "4g"


    }
    lintOptions {
//        lintConfig file("$project.rootDir/tools/rules-lint.xml")
        abortOnError false
        htmlOutput file("$project.buildDir/outputs/lint/lint.html")
        warningsAsErrors false
        xmlReport true
    }

    buildTypes {
        release {
            minifyEnabled true
            debuggable false
            jniDebuggable true
            signingConfig signingConfigs.config
            renderscriptDebuggable true
            shrinkResources true
            proguardFile '/home/abhinav/Android/Sdk/tools/proguard/yakshaproguard.txt'
        }
        debug {
            minifyEnabled false
            proguardFile '/home/abhinav/Android/Sdk/tools/proguard/yakshaproguard.txt'
            multiDexKeepFile file('multidex-config.txt')
        }

    }

    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/DEPENDENCIES'
                exclude 'META-INF/notice.txt'
                exclude 'META-INF/license.txt'
                exclude 'META-INF/dependencies.txt'
                exclude 'META-INF/LGPL2.1'
            }
    testOptions {
        unitTests.returnDefaultValues = true
        unitTests {


            all {
                jvmArgs '-XX:MaxPermSize=256m'
                if (it.name == 'testDebug') {
                    systemProperty 'debug', 'true'
                }
                if (it.name == 'connectedDebugAndroidTest') {

                }
            }
        }
    }
    configurations {
    }
}

dependencies {

    //    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.3.0'
    compile 'com.android.support:design:25.3.0'
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.google.android.gms:play-services:10.2.1'
    compile project(':realmtenedbservice')
    compile project(':tenewsrestlib')
    compile project(':TeneLocationLib')
    compile project(':SecurityYsc')
    compile project(':library')
    debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
    releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
    testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:recyclerview-v7:25.3.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.birbit:android-priority-jobqueue:2.0.1'
    compile 'com.fasterxml.jackson.core:jackson-core:2.7.3'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
    compile 'io.reactivex:rxjava:1.1.0'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.google.maps.android:android-maps-utils:0.4+'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'io.realm:android-adapters:1.4.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.sromku:simple-storage:1.2.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'joda-time:joda-time:2.9.7'
    compile 'id.zelory:compressor:1.0.4'
    compile 'io.reactivex:rxandroid:1.2.1'
}

我在运行项目时遇到这个错误,你能给出建议为什么会这样吗

Information:Gradle tasks [:app:assembleDebug]
Warning:Using incompatible plugins for the annotation processing: android-apt. This may result in an unexpected behavior.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class
Information:BUILD FAILED
Information:Total time: 18.768 secs
Information:1 error
Information:1 warning
Information:See complete output in console

最佳答案

你可以排除那个显示重复的类

configurations {
all*.exclude group: 'org.apache.commons'
}

关于运行项目时 Android Gradle 构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43138840/

相关文章:

java - 我想更改滚动时应用程序工具栏的颜色

android服务永远不应该停止

android - 如何在 Google Map API v2 中的 MapFragment 上显示多个标记?

安卓测试 : asserting an activity transitioned to another

java - 屏幕旋转后恢复 fragment 中微调器的位置

android - 按下选项菜单时关闭弹出窗口

Android - 支持库 v24.0.0 中的矢量绘图

java - finish() 什么时候执行?

android - Xamarin 和 RestSharp - 异步调用挂起/永不返回

android - 微调器显示像对话框