Unity升级相关问题

Unity从2021.3.31升级到2022.3.59之后,使用Unity的出包接口,运行到GradleBuild会出现两种报错:

1、

Execution failed for task ':unityLibrary:packageReleaseResources'.
> Error while evaluating property 'namespace' of task ':unityLibrary:packageReleaseResources'
   > Failed to calculate the value of task ':unityLibrary:packageReleaseResources' property 'namespace'.
      > Failed to calculate the value of property 'namespace'.
         > Package Name not found in xxx\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\src\main\AndroidManifest.xml, and namespace not specified. Please specify a namespace for the generated R and BuildConfig classes via android.namespace in the module's build.gradle file like so:
           
           android {
               namespace 'com.example.namespace'
           },
2、
Execution failed for task ':launcher:mergeDexRelease'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingTaskDelegate
   > There was a failure while executing work items
      > A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingWorkAction
         > com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
           Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
           Type {packagename}.android.BuildConfig is defined multiple times: xxx\Library\Bee\Android\Prj\Mono2x\Gradle\launcher\build\intermediates\project_dex_archive\release\out\billion\cash\free\games\jackpot\casino\slots\android\BuildConfig.dex, xxx\Library\Bee\Android\Prj\Mono2x\Gradle\launcher\build\intermediates\sub_project_dex_archive\release\out\6b9d648f1114bbf97287d57921a7f24786f19cc3d9553f24c70f33c3cdc70167_7.jar:classes.dex

这两个报错的原因是同一个问题,错误2的提示: ​**BuildConfig 类被多次定义**,是因为多个模块(如 :launcher 和 :unityLibrary)使用了相同的 namespace,导致生成的 BuildConfig 类重复,

结合报错得出结论:gradle工程中多个模块中应该有相同的 namespace ,导致生成的BuildConfig 类重复,再根据错误一的提示,去修改指定模块的namespace 即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值