【问题标题】:Android Gradle Duplicate files copied in APK META-INFAndroid Gradle 在 APK META-INF 中复制的重复文件
【发布时间】:2016-12-13 01:16:06
【问题描述】:

我尝试在我的 android 应用程序中添加 spring,但应用程序没有运行。 我真的不知道为什么我的跑步失败了。你能帮我解决这个问题吗?谢谢

这是我的 app/build.gradle 配置:

apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
    applicationId "com.nizar.abdelhedi.accesscontrol"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        resValue "string", "host_name", "access-control-web/rest/roles/attendance"

    }
}
   configurations {
    all*.exclude module: 'httpclient'
    all*.exclude module: 'commons-logging'
}
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'
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.github.vajro:MaterialDesignLibrary:1.6'
    compile 'com.github.blackfizz:eazegraph:1.2.2@aar'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.github.lecho:hellocharts-library:1.5.8@aar'
    compile 'org.springframework:spring-context:4.2.7.RELEASE'
}
}

这是我的错误信息

信息:Gradle 任务 [:app:assembleDebug] :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAnimatedVectorDrawable2340Library UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72340Library UP-TO-DATE :app:prepareComAndroidSupportDesign2340Library UP-TO-DATE :app:prepareComAndroidSupportRecyclerviewV72340Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42340Library UP-TO-DATE :app:prepareComAndroidSupportSupportVectorDrawable2340Library UP-TO-DATE :app:prepare ComGithubBlackfizzEazegraph122Library UP-TO-DATE :app:prepareComGithubLechoHellochartsLibrary158Library UP-TO-DATE :app:prepare ComGithubVajroMaterialDesignLibrary16Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl 最新 :app:compileDebugRenderscript 最新 :app:generateDebugBuildConfig 最新 :app:mergeDebugShaders 最新 :app:compileDebugShaders 最新 :app:generateDebugAssets 最新 :app:mergeDebugAssets 最新 :app:generateDebugResValues 最新 :app:generateDebugResources 最新 :app:mergeDebugResources 最新 :app:processDebugManifest :app:processDebugResources :app:generateDebugSources :app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE :app:compileDebugJavaWithJavac 最新 :app:compileDebugNdk 最新 :app:compileDebugSources 最新 :app:buildInfoDebugLoader :app:transformClassesWithExtractJarsForDebug 最新 :app:transformClassesWithInstantRunVerifierForDebug 最新 :app:transformClassesWithJavaResourcesVerifierForDebug 最新 :app:mergeDebugJniLibFolders 最新 :app:transformNative_libsWithMergeJniLibsForDebug 最新 :app:processDebugJavaRes 最新 :app:transformResourcesWithMergeJavaResForDebug 失败 错误:任务':app:transformResourcesWithMergeJavaResForDebug'的执行失败。 > com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: 在 APK META-INF/spring.schemas 中复制的文件重复 文件 1:C:\Users\abdelhedi\.gradle\caches\modules-2\files-2.1\org.springframework\spring-context\4.2.7.RELEASE\289f2906943827d37de89240dbac8fe4b315a838\spring-context-4.2.7.RELEASE.jar 文件2:C:\Users\abdelhedi\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aop\4.2.7.RELEASE\bd65f97ba61fd3dcc0b74765d3fa388aeb388aa7\spring-aop-4.2.7.RELEASE.jar 文件 3:C:\Users\abdelhedi\.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\4.2.7.RELEASE\ae0501728c0ee072e25cb5e11b63b883c0786b4b\spring-beans-4.2.7.RELEASE.jar 信息:构建失败 信息:总时间:2.634 秒 信息:1个错误 信息:0 个警告 信息:在控制台中查看完整的输出

【问题讨论】:

    标签: android spring


    【解决方案1】:

    将另一个添加到您的packagingOptions

    exclude 'META-INF/spring.schemas'
    

    编辑:继续添加!看起来你有一大堆重复项

    每当你看到Exception: Duplicate files copied in APK BLAH/blah.blah

    添加另一个exclude 'BLAH/blah.blah'

    【讨论】:

    • 不起作用错误:任务':app:transformResourcesWithMergeJavaResForDebug'的执行失败。 > com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: APK META-INF/spring.tooling 中复制的文件重复
    • 我认为我知道我写的 exclude 'META-INF/spring.schemas' 不止一次并继续添加它,但没有任何改变。
    • 不...你看到你的新错误了吗?现在是 META-INF/spring.tooling 排除它!再建一次!如果弹出不同的“复制到...中的重复文件”,请排除其中的名称!重复...