[Unity] Error:annotationType(): unrecognized Attribute name MODULE

一、遇到的问题

  1. 问题背景

Unity 2020.1.14发布Apk包上架GooglePlay商店,要求API Target级别为31,也就是Android12环境,打包的时候报错

(1)整体错误信息
在这里插入图片描述
(2)警告信息

Starting a Gradle Daemon, 1 incompatible and 4 stopped Daemons could not be reused, use --status for details
> Configure project :launcher
WARNING: The option 'android.enableR8' is deprecated and should not be used anymore.
It will be removed in a future version of the Android Gradle plugin, and will no longer allow you to disable R8.
> Task :unityLibrary:preBuild UP-TO-DATE
> Task :launcher:preBuild UP-TO-DATE
> Task :unityLibrary:preReleaseBuild UP-TO-DATE
> ...
39 actionable tasks: 39 executed
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

(3)Build失败错误信息

stderr[
编译器 (1.8.0-adoptopenjdk) 中出现异常错误。如果在 Bug Database (http://bugs.java.com) 中没有找到该错误, 请通过 Java Bug 报告页 (http://bugreport.java.com) 建立该 Java 编译器 Bug。请在报告中附上您的程序和以下诊断信息。谢谢。
java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.tools.javac.util.UnsharedNameTable$NameImpl)
	at com.sun.tools.javac.util.Assert.error(Assert.java:133)
	at com.sun.tools.javac.code.TypeAnnotations.annotationType(TypeAnnotations.java:231)
	at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.separateAnnotationsKinds(TypeAnnotations.java:294)
...
  1. 尝试的方法

(1)最开始集中在根据Build的失败的错误信息,查找解决方案
(2)升级过Unity,修改过Gradle版本,都无效,最后开始尝试根据警告信息解决,然后成了

二、可能的原因

Unity 2020版本存在的问题,Unity还没解决

三、解决方案

  1. 找到PlayerSettings->Publishing Settings,勾选Custom Base Gradle Template
    在这里插入图片描述
  2. 项目->Assets->Plugins->Android文件夹,打开baseProjectTemplate.gradle文件,修改gradle版本为3.4.0,重新打包,结束

找错了方向,难搞

猜你喜欢

转载自blog.csdn.net/weixin_42186644/article/details/123410084
今日推荐