【Unity打包APK报错BuildConfig is defined multiple times】

Unity打包APK报错BuildConfig is defined multiple times

  • 错误信息
    • 解决办法
        • 步骤1
        • 步骤2

错误信息

D:\Project\RichTownU3D_2021\Library\Bee\Android\Prj\IL2CPP\Gradle\launcher\build\intermediates\project_dex_archive\release\out\com\richtown\android\richtown\BuildConfig.dex: 
D8: Type com.richtown.android.richtown.BuildConfig is defined multiple times: 
D:\Project\RichTownU3D_2021\Library\Bee\Android\Prj\IL2CPP\Gradle\launcher\build\intermediates\project_dex_archive\release\out\com\richtown\android\richtown\BuildConfig.dex, 
D:\Project\RichTownU3D_2021\Library\Bee\Android\Prj\IL2CPP\Gradle\launcher\build\intermediates\external_libs_dex\release\mergeExtDexRelease\classes.dex

解决办法

步骤1

将这段代码添加到提示信息对应的build.gradle中,我这里是D:\Project\RichTownU3D_2021\Library\Bee\Android\Prj\IL2CPP\Gradle\launcher

afterEvaluate {
    generateReleaseBuildConfig.enabled = false
    generateDebugBuildConfig.enabled =false
}

添加的位置

apply plugin: 'com.android.application'

afterEvaluate {
    generateReleaseBuildConfig.enabled = false
    generateDebugBuildConfig.enabled =false
}
dependencies {
    implementation project(':unityLibrary')
    }
步骤2

打开提示信息对应的bulid文件夹路径,我这里是
D:\Project\RichTownU3D_2021\Library\Bee\Android\Prj\IL2CPP\Gradle\launcher\build,删除整个build文件夹,然后重新打包。

你可能感兴趣的:(Unity,unity,android,gradle)