运行构建 gradle 时,离子电容器运行 android 失败。 毕业失败 '* 出了什么问题:提供的 javaHome 必须是有效目录。 您提供:C:\Program Files\Java\jre1.8.0_321' gradle 失败,因为他在 'C:\Program Files\Jav ...
提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供 中文繁体 英文版本 中英对照 版本,有任何建议请联系yoyou2525@163.com。
我创建了一个带有以下变量的 Ionic 6.19.1 应用程序。gradle 文件和“离子电容器运行 android”命令运行良好,应用程序运行良好:
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 = 26 替换 compileSdkVersion = 30,“离子电容器运行 android”命令会产生此错误:
> 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 Studio 中更新
预先感谢您的帮助
compileSdkVersion
是用于编译您的应用程序的 SDK 的版本。 If you use compileSdkVersion
26 you are using the SDK that was released for android 8 (Android O), so it doesn't understand what VERSION_CODES.P
means, because Android P was launched after Android O and didn't exist on Android O SDK .
您不应该使用compileSdkVersion
26, compileSdkVersion
是可配置的,因此您可以根据需要使用较新的版本,但不能使用较旧的版本。
不太确定你为什么要这样做,但谷歌将要求在 8 月份为新应用程序使用 SDK 32。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.