侧边栏壁纸
博主头像
X博主等级

一个移动端码农

  • 累计撰写 30 篇文章
  • 累计创建 40 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

jitpack编译失败An exception has occurred in the compiler (1.8.0_292)

X
X
2023-03-15 / 0 评论 / 0 点赞 / 726 阅读 / 349 字

jitpack编译失败

之前都可以正常上传的,直到修改targetSdkVersion为30并且将android studio更新到Android Studio Dolphin | 2021.3.1 Patch 1 后就不行了.

详细报错日志传送门

核心错误log

20 actionable tasks: 17 executed, 3 up-to-date
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
An exception has occurred in the compiler (1.8.0_292). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
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)


解决方法

是因为targetSdkVersion 修改为30及以上后 需要更新android studio和jdk11 , jitpack默认是使用jdk1.8 所以会编译失败

  • 方法
    在项目跟目录增加jitpack.yml文件内容如下,主要告诉jitpack使用jdk11

before_install:
  - sdk install java 11.0.10-open
  - sdk use java 11.0.10-open

jdk:
  - openjdk11

image-1678875746014

  • 如果这样还无法编译通过,可以更新gradle版本
dependencies {
        classpath 'com.android.tools.build:gradle:7.3.1'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

  • gradle-wrapper.properties内容
#Thu May 09 11:54:15 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip


0

评论区