【问题标题】:More than one file was found with OS independent path 'META-INF/groovy-release-info.properties'发现多个文件具有独立于操作系统的路径“META-INF/groovy-release-info.properties”
【发布时间】:2019-02-08 20:55:53
【问题描述】:

如果我尝试构建我的应用程序,我会收到此错误:

DuplicateRelativeFileException: 发现多个文件具有独立于操作系统的路径“META-INF/groovy-release-info.properties”

还有这个:

原因:com.android.tools.r8.utils.AbortException:错误:MethodHandle.invoke 和 MethodHandle.invokeExact 仅支持从 Android O (--min-api 26) 开始

我的 build.gradle 文件:

apply plugin: 'com.android.application'

android {
compileSdkVersion 27

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
    applicationId "com.example.example"
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 
    "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
   }
}

dependencies {
   implementation fileTree(dir: 'libs', include: ['*.jar'])
   implementation 'com.android.support:appcompat-v7:27.1.1'
   implementation 'com.android.support.constraint:constraint-layout:1.1.3'
   implementation 'com.squareup.okhttp3:okhttp:3.13.0'
   implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.5'
   implementation 'com.fasterxml.jackson.core:jackson-core:2.8.5'
   implementation 'com.fasterxml.jackson.core:jackson-annotations:2.8.5'
   implementation 'io.rest-assured:json-path:3.3.0'
   testImplementation 'org.mockito:mockito-core:1.10.19'
   testImplementation 'junit:junit:4.12'
   testImplementation 'com.squareup.okhttp3:mockwebserver:3.13.0'
   androidTestImplementation 'com.android.support.test:runner:1.0.2'
   androidTestImplementation 'com.android.support.test.espresso:espresso-
   core:3.0.2'
}

我尝试通过在我的 gradle.build 文件中添加以下代码来解决这个问题:

packagingOptions {
    exclude 'META-INF/groovy-release-info.properties'
}

但是我会得到这个错误:

com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\[myUserNamePlaceholder]\.gradle\caches\modules-2\files-2.1\org.codehaus.groovy\groovy\2.4.15\74b7e0b99526c569e3a59cb84dbcc6204d601ee6\groovy-2.4.15.jar

请你帮帮我。我已经尝试解决这个问题好几个小时了。我感谢任何对我有很大帮助的答案。

【问题讨论】:

    标签: java android android-studio exception


    【解决方案1】:

    尝试使用 pickFirst 仅选择一个文件:

    packagingOptions {
        pickFirst 'META-INF/groovy-release-info.properties'
    }
    

    【讨论】:

    • 非常感谢您的帮助。不幸的是,你的建议并没有解决我的问题。另外我得到以下异常com.android.tools.r8.utils.AbortException: Error: MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)
    【解决方案2】:

    我设法解决了这个问题。当我将以下依赖项插入到我的 gradle 文件中时出现了问题:

    implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.5'
    implementation 'com.fasterxml.jackson.core:jackson-core:2.8.5'
    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.8.5'
    

    经过长时间的研究,我找到了解决方案。我必须在我的 build.gradle 文件中添加编译选项:

    android {
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
        ...
    }
    

    还有我的 gradle.properties

    android.enableD8=true
    

    之后就成功了。

    【讨论】:

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