【问题标题】:'More than one file was found with OS independent path project.properties' Error in android'在独立于操作系统的路径 project.properties 中发现了多个文件' android 中的错误
【发布时间】:2017-12-04 09:21:39
【问题描述】:

在我的项目中添加 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'

我尝试了herehere 提供的解决方案,但没有成功。 我还尝试将 gradle 降级到 2.3 版,但这也没有解决问题。

我的 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'

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

}

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

【问题讨论】:

  • implementation替换compile,用androidTestImplementation替换androidTestCompile,用testImplementation替换testCompile并在defaultConfig中添加multiDexEnabled true
  • 清理并重建项目。就我而言,它工作正常。
  • @Ahishek 不,它不起作用

标签: java android android-gradle-plugin android-studio-3.0


【解决方案1】:

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

packagingOptions {

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

【讨论】:

  • 这是解决方案还是变通方法?我们为什么要包含这些文件?
  • 我认为这与您添加到项目中的库有关。他们可以在构建时创建额外的 .properties 文件,因此系统会混淆使用哪一个。我也不确定细节。
【解决方案2】:

你可以在你的Project/app/build.gradle里面添加这个android{}

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'
}

【讨论】:

    【解决方案3】:

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

     defaultConfig {
        multiDexEnabled true
     }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-02
      • 2018-11-19
      • 2018-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-03
      • 1970-01-01
      相关资源
      最近更新 更多