![](/img/trans.png)
[英]ionic build android :CordovaLib:compileDebugJavaWithJavac
[英]ionic build failing for Android TargetSDK 31 :CordovaLib:compileReleaseJavaWithJavac FAILED
我已經解決了這個問題,只是把它放在這里以供遇到同樣問題的任何人使用:
當我嘗試上傳我的 Ionic 應用程序的 Android 版本時,Google Play 開發者控制台告訴我我需要一個 31 的目標 SDK。
我能夠通過更新我的config.xml
來更新這一行
<preference name="android-targetSdkVersion" value="31" />
但是當我構建我的應用程序時,它會失敗並出現以下錯誤,而沒有任何真正指示下一步該做什么
Task :CordovaLib:compileReleaseJavaWithJavac FAILED
An exception has occurred in the compiler (1.8.0_202). 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)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':CordovaLib:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 3s
22 actionable tasks: 2 executed, 20 up-to-date
Command failed with exit code 1: /Users/danielread/Documents/GitHub/fitdegree/clients/apps/app/platforms/android/gradlew :app:bundleRelease -b /Users/danielread/Documents/GitHub/fitdegree/clients/apps/app/platforms/android/build.gradle
我可以通過在我的計算機上更新 Java 的版本來解決這個問題。
以前我使用的是 1.8.0 版本,在將我的 Java 升級到版本 11 后,構建成功。
https://www.oracle.com/java/technologies/downloads/#java11
我還更新了我的 gradle 版本,但不確定這是否必要
brew upgrade gradle
brew install gradle
我安裝了 Java 11 它解決了我的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.