首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >离子电容器运行android :任务:电容器-应用程序:编译compileDebugJavaWithJavac失败

离子电容器运行android :任务:电容器-应用程序:编译compileDebugJavaWithJavac失败
EN

Stack Overflow用户
提问于 2022-07-01 09:21:00
回答 1查看 587关注 0票数 0

我用以下variables.gradle文件创建了一个Ionic 6.19.1应用程序,“离子电容器运行android”命令工作得很好,应用程序工作得很好:

代码语言:javascript
运行
复制
ext {
    minSdkVersion = 26
    compileSdkVersion = 30
    targetSdkVersion = 30
    androidxActivityVersion = '1.2.0
    androidxAppCompatVersion = '1.2.0
    androidxCoordinatorLayoutVersion = '1.1.0
    androidxCoreVersion = '1.3.2
    androidxFragmentVersion = '1.3.0
    junitVersion = '4.13.1
    androidxJunitVersion = '1.1.2
    androidxEspressoCoreVersion = '3.3.0
    cordovaAndroidVersion = '7.0.0'
}

但是,如果我将compileSdkVersion = 30替换为compileSdkVersion = 26,则“离子电容器运行安卓”命令会产生以下错误:

代码语言:javascript
运行
复制
 > Task :capacitor-app:compileDebugJavaWithJavac FAILED
[capacitor] /Users/christophe/Documents/Sources/sylva/sycub/node_modules/@capacitor/app/android/src/main/java/com/capacitorjs/plugins/app/AppPlugin.java:84: error: cannot find symbol
[capacitor] if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
[capacitor] ^
[capacitor] symbol: variable P
[capacitor] location: class VERSION_CODES
[capacitor] /Users/christophe/Documents/Sources/sylva/sycub/node_modules/@capacitor/app/android/src/main/java/com/capacitorjs/plugins/app/AppPlugin.java:85: error: cannot find symbol
[capacitor] data.put("build", Long.toString(pinfo.getLongVersionCode()));
[capacitor] ^
[capacitor] symbol: method getLongVersionCode()
[capacitor] location: variable pinfo of type PackageInfo
[capacitor] 2 errors
[capacitor]         
[capacitor] FAILURE: Build failed with an exception.
[capacitor]         
[capacitor] * What went wrong:
[capacitor] Execution failed for task ':capacitor-app:compileDebugJavaWithJavac'.
[capacitor] > Compilation failed; see the compiler error output for details.
[capacitor]         
[capacitor] * Try:
[capacitor] > Run with --stacktrace option to get the stack trace.
[capacitor] > Run with --info or --debug option to get more log output.
[capacitor] > Run with --scan to get full insights.
[capacitor]         
[capacitor] * Get more help at https://help.gradle.org
[capacitor]         
[capacitor] Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
[capacitor]         
[capacitor] You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
[capacitor]         
[capacitor] See https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings
[capacitor] 131 actionable tasks: 36 executed, 95 up-to-date
[capacitor]         
[capacitor] BUILD FAILED in 1s
[capacitor]         
[ERROR] An error occurred while running subprocess capacitor.

Java版本是"17“2021-09-14 LTS

Gradle已在Android中更新

预先感谢您的帮助

EN

回答 1

Stack Overflow用户

发布于 2022-07-01 22:23:57

compileSdkVersion是用于编译应用程序的SDK版本。如果使用compileSdkVersion 26,则使用的是为Android8 (Android )发布的SDK,因此它不理解VERSION_CODES.P的含义,因为android是在Android之后发布的,并且在Android上并不存在。

您不应该使用compileSdkVersion 26,compileSdkVersion是可配置的,因此您可以在需要时使用较新的版本,但永远不能使用旧的版本。

不太清楚你为什么要这么做,但谷歌需要在8月份将SDK 32用于新的应用程序。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72827093

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档