【问题标题】:Android Studio 3.0 beta2Android Studio 3.0 beta2
【发布时间】:2018-02-01 09:46:26
【问题描述】:

当我构建我的项目时,出现以下错误:

错误:com.android.builder.merge.DuplicateRelativeFileException:找到多个文件,其独立于操作系统的路径为“META-INF/app_debug.kotlin_module”

这是我的 build.gradle 文件

  buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        google()
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
    }

    apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'
    apply plugin: 'kotlin-android'
    apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.e9innovation.infrastructure"
        multiDexEnabled true
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

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

        debug {
            signingConfig signingConfigs.debug
        }
    }

    signingConfigs {
        debug {
            storeFile file('../keystores/debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }

    lintOptions {
        abortOnError false
    }
}

ext {
    supportLibVersion = "26.0.1"
    playServicesVersion = "11.2.0"
}

repositories {
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
    google()
}


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'
    })
    testCompile 'junit:junit:4.12'
    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile "com.android.support:design:${supportLibVersion}"
    compile "com.android.support:support-v4:${supportLibVersion}"
    compile "com.android.support:cardview-v7:${supportLibVersion}"
    compile "com.android.support:exifinterface:${supportLibVersion}"
    compile "com.google.android.gms:play-services-base:${playServicesVersion}"
    compile "com.google.android.gms:play-services-maps:${playServicesVersion}"
    compile "com.google.android.gms:play-services-gcm:${playServicesVersion}"
    compile "com.google.android.gms:play-services-location:${playServicesVersion}"
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile "com.android.support:percent:${supportLibVersion}"
    testCompile 'junit:junit:4.12'


    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

    //apache commons
    compile 'org.apache.commons:commons-lang3:3.5'

    compile "com.google.firebase:firebase-database:${playServicesVersion}"
    compile "com.google.firebase:firebase-storage:${playServicesVersion}"
    compile "com.google.firebase:firebase-auth:${playServicesVersion}"
    compile 'com.firebase:geofire-android:2.1.1'

    compile 'com.github.bumptech.glide:glide:4.0.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0'

    compile 'com.github.chrisbanes:PhotoView:2.1.3'

    compile project(path: ':searchView')
    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true;
    }
}

apply plugin: 'com.google.gms.google-services'

附:我将我的 Android 工作室升级到 3.0 beat-2 并且出现了这个问题。 谁知道它是关于什么的?

【问题讨论】:

  • 出于某种原因,项目中打包在一起的多个模块的 Kotlin 输出包含相同的 *.kotlin_module 文件,或者尝试打包重复的 Kotlin 输出(更有可能)。我会尽快尝试重现该问题。你的项目是开源的吗?
  • @hotkey 不,我的项目不是开源的,感谢您的帮助,让我知道我们可以面对面交谈!
  • 也发生在 AS 3.0 版本中。

标签: android android-studio android-gradle-plugin kotlin build.gradle


【解决方案1】:

首先使缓存无效并重新启动,然后清理项目并重建它。希望它有所帮助。

【讨论】:

  • 谢谢,这救了我!
  • 很高兴为您提供帮助:)
【解决方案2】:

首先根据您的操作系统使用以下命令清理缓存:

在 Windows 上:

gradlew cleanBuildCache

在 Mac 或 Linux 上:

./gradlew cleanBuildCache

在此清理并重建项目之后。

【讨论】:

    【解决方案3】:

    添加 app:build.gradle 文件

    packagingOptions {
        exclude 'META-INF/app_debug.kotlin_module'
    }
    

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-29
      • 2018-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-12
      相关资源
      最近更新 更多