【问题标题】:Kotline Multiplatform Mobile: Entry name 'META-INF/androidx.vectordrawable_vectordrawable.version' collidedKotlin Multiplatform Mobile:条目名称“META-INF/androidx.vectordrawable_vectordrawable.version”冲突
【发布时间】:2026-01-26 12:50:02
【问题描述】:

我是 kotlin multiplaform mobile 的新手,正在尝试一下。我在使用 Build > Generate Signed Bundled / Apk... 在 android studio 4.0.1 中构建签名 apk 时遇到了这个问题。出现此消息的构建错误

Entry name 'META-INF/androidx.vectordrawable_vectordrawable.version' collided

我尝试了以下步骤:

  1. 文件 > 使缓存无效/重新启动
  2. 构建 > 清理项目
  3. 构建 > 重建项目

还尝试从应用文件夹中删除 apk,然后重做该过程。还是有这个问题。

这是构建输出:

Executing tasks: [:androidApp:assembleDebug, :androidApp:assembleRelease] in project C:\Users\localpc\AndroidStudioProjects\MyApplication


> Configure project :shared
Kotlin Multiplatform Projects are an Alpha feature.

Some Kotlin/Native targets cannot be built on this mingw_x64 machine and are disabled:
    * In project ':shared':
        * targets 'iosArm64', 'iosX64' (can be built with a macos_x64 host)
To hide this message, add 'kotlin.native.ignoreDisabledTargets=true' to the Gradle properties.


> Task :androidApp:preBuild UP-TO-DATE
> Task :androidApp:preDebugBuild UP-TO-DATE
> Task :shared:preBuild UP-TO-DATE
> Task :shared:preDebugBuild UP-TO-DATE
> Task :shared:compileDebugAidl NO-SOURCE
> Task :androidApp:compileDebugAidl NO-SOURCE
> Task :shared:packageDebugRenderscript NO-SOURCE
> Task :androidApp:compileDebugRenderscript NO-SOURCE
> Task :androidApp:generateDebugBuildConfig UP-TO-DATE
> Task :androidApp:generateDebugResValues UP-TO-DATE
> Task :androidApp:generateDebugResources UP-TO-DATE
> Task :shared:compileDebugRenderscript NO-SOURCE
> Task :shared:generateDebugResValues UP-TO-DATE
> Task :shared:generateDebugResources UP-TO-DATE
> Task :shared:packageDebugResources UP-TO-DATE
> Task :androidApp:mergeDebugResources UP-TO-DATE
> Task :androidApp:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :androidApp:extractDeepLinksDebug UP-TO-DATE
> Task :shared:extractDeepLinksDebug UP-TO-DATE
> Task :shared:processDebugManifest UP-TO-DATE
> Task :androidApp:processDebugManifest UP-TO-DATE
> Task :shared:compileDebugLibraryResources UP-TO-DATE
> Task :shared:parseDebugLocalResources UP-TO-DATE
> Task :shared:generateDebugRFile UP-TO-DATE
> Task :androidApp:processDebugResources UP-TO-DATE
> Task :shared:generateDebugBuildConfig UP-TO-DATE
> Task :shared:compileDebugKotlinAndroid UP-TO-DATE
> Task :shared:javaPreCompileDebug UP-TO-DATE
> Task :shared:compileDebugJavaWithJavac UP-TO-DATE
> Task :shared:bundleLibCompileToJarDebug UP-TO-DATE
> Task :androidApp:compileDebugKotlin UP-TO-DATE
> Task :androidApp:javaPreCompileDebug UP-TO-DATE
> Task :androidApp:compileDebugJavaWithJavac UP-TO-DATE
> Task :androidApp:compileDebugSources UP-TO-DATE
> Task :androidApp:mergeDebugShaders UP-TO-DATE
> Task :androidApp:compileDebugShaders NO-SOURCE
> Task :androidApp:generateDebugAssets UP-TO-DATE
> Task :shared:mergeDebugShaders UP-TO-DATE
> Task :shared:compileDebugShaders NO-SOURCE
> Task :shared:generateDebugAssets UP-TO-DATE
> Task :shared:packageDebugAssets UP-TO-DATE
> Task :androidApp:mergeDebugAssets UP-TO-DATE
> Task :androidApp:processDebugJavaRes NO-SOURCE
> Task :shared:processDebugJavaRes NO-SOURCE
> Task :shared:bundleLibResDebug UP-TO-DATE
> Task :androidApp:mergeDebugJavaResource UP-TO-DATE
> Task :androidApp:checkDebugDuplicateClasses UP-TO-DATE
> Task :androidApp:mergeExtDexDebug UP-TO-DATE
> Task :shared:bundleLibRuntimeToJarDebug UP-TO-DATE
> Task :androidApp:dexBuilderDebug UP-TO-DATE
> Task :androidApp:mergeLibDexDebug UP-TO-DATE
> Task :androidApp:mergeProjectDexDebug UP-TO-DATE
> Task :androidApp:mergeDebugJniLibFolders UP-TO-DATE
> Task :shared:mergeDebugJniLibFolders UP-TO-DATE
> Task :shared:mergeDebugNativeLibs UP-TO-DATE
> Task :shared:stripDebugDebugSymbols NO-SOURCE
> Task :shared:copyDebugJniLibsProjectOnly UP-TO-DATE
> Task :androidApp:mergeDebugNativeLibs UP-TO-DATE
> Task :androidApp:stripDebugDebugSymbols NO-SOURCE
> Task :androidApp:validateSigningDebug UP-TO-DATE
> Task :androidApp:packageDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':androidApp:packageDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Entry name 'META-INF/androidx.vectordrawable_vectordrawable.version' collided

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
41 actionable tasks: 1 executed, 40 up-to-date

当我在没有签名的情况下构建它成功完成,但在执行签名 apk 构建时失败。不知道出了什么问题。感谢您的帮助。

【问题讨论】:

    标签: android-studio kotlin gradle kotlin-multiplatform


    【解决方案1】:

    我不知道它到底在哪里冲突。但是排除这个列表似乎可以解决问题,我可以完成签名 apk 的构建。如果我能找到更多,会更新更多:

    将此添加到您的 build.gradle.kts(使用 kotlin dsl)

    android {
        compileSdkVersion(29)
        defaultConfig {
            applicationId = "com.example.myapplication.androidApp"
            minSdkVersion(24)
            targetSdkVersion(29)
            versionCode = 1
            versionName = "1.0"
        }
        buildTypes {
            getByName("release") {
                isMinifyEnabled = false
            }
        }
    
        ////// ADD THIS PART //////////
        packagingOptions {
            exclude("META-INF/androidx.vectordrawable_vectordrawable.version")
            exclude("META-INF/androidx.loader_loader.version")
            exclude("META-INF/androidx.lifecycle_lifecycle-livedata.version")
            exclude("META-INF/androidx.lifecycle_lifecycle-livedata.version")
            exclude("kotlin/annotation/annotation.kotlin_builtins")
            exclude("META-INF/androidx.lifecycle_lifecycle-runtime.version")
        }
    }
    

    【讨论】: