java “在操作系统独立路径 project.properties 中找到了多个文件”android 中的错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47630015/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 09:42:42  来源:igfitidea点击:

'More than one file was found with OS independent path project.properties' Error in android

javaandroidandroid-gradle-pluginandroid-studio-3.0

提问by IldiX

I'm getting this error after I added google translate api on my project. I am using Android Studio 3.0, Gradle 3.0.0.

在我的项目中添加 google translate api 后,我收到此错误。我使用的是 Android Studio 3.0、Gradle 3.0.0。

 Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
 More than one file was found with OS independent path 'project.properties'

I have tried the solution presented hereand here, but with no success. Also I tried downgrading gradle to version 2.3 but that didn't solve the problem either.

我已经尝试了此处此处介绍的解决方案,但没有成功。我也尝试将 gradle 降级到 2.3 版,但这也没有解决问题。

My build.gradle file :

我的 build.gradle 文件:

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.aim.fjalortest"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

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

    packagingOptions {
        exclude 'META-INF/project.properties'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile 'com.android.support:appcompat-v7:25.3.1'
    testCompile 'junit:junit:4.12'

    compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
    compile 'com.android.support:recyclerview-v7:25.4.0'
    compile 'com.google.android.gms:play-services-vision:9.0.0+'
    compile 'com.android.support:design:25.4.0'
    compile 'com.google.cloud:google-cloud-translate:1.12.0'
    //annotationProcessor 'com.google.cloud:google-cloud-translate:1.12.0'

    //Hymanson
    compile 'com.fasterxml.Hymanson.core:Hymanson-databind:2.8.5'
    compile 'com.fasterxml.Hymanson.core:Hymanson-core:2.8.5'
    compile 'com.fasterxml.Hymanson.core:Hymanson-annotations:2.8.5'

}

Can anyone help me figuring out what's causing this error?

谁能帮我找出导致此错误的原因?

回答by IldiX

Adding the following lines solved my problem:

添加以下几行解决了我的问题:

packagingOptions {

        exclude 'project.properties'
        exclude 'META-INF/INDEX.LIST'
    }

回答by Shaaban Ebrahim

You can add this in yourProject/app/build.gradle inside android{}

您可以在 android{} 内的 yourProject/app/build.gradle 中添加它

packagingOptions {
      exclude 'META-INF/DEPENDENCIES'
      exclude 'META-INF/LICENSE'
      exclude 'META-INF/LICENSE.txt'
      exclude 'META-INF/license.txt'
      exclude 'META-INF/NOTICE'
      exclude 'META-INF/NOTICE.txt'
      exclude 'META-INF/notice.txt'
      exclude 'META-INF/ASL2.0'
}

回答by IldiX

Try adding multidexEnabled to your app-level build.gradle, as follows :

尝试将 multidexEnabled 添加到您的应用程序级 build.gradle,如下所示:

 defaultConfig {
    multiDexEnabled true
 }