我试图做“类星体构建-M Android”根据文档https://quasar.dev/quasar-cli-vite/developing-cordova-apps/build-commands#building-for-production我按照准备说明https://quasar.dev/quasar-cli-vite/developing-cordova-apps/preparation,所有系统变量都指定和路径指定https://i.stack.imgur.com/FPKt2.pnghttps://i.stack.imgur.com/iRegi.png
文档指出Gradle版本4.10.3是必需的,Java下载链接建议安装版本8。在这些条件下,如果我从项目的“src-cordova”文件夹中执行“cordova requirements”,那么我不会得到任何错误
PS C:\Users\Maksim\Desktop\lmschat-mobile\src-cordova> cordova requirements
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-34,android-UpsideDownCakePrivacySandbox,android-TiramisuPrivacySandbox,android-33,android-28,android-27,android-26
Gradle: installed C:\Program Files\Gradle\gradle-4.10.3\bin\gradle.BAT
但是当通过“cordova build --release --warning-mode=all”进行构建时,我会得到以下错误
PS C:\Users\Maksim\Desktop\lmschat-mobile\src-cordova> cordova build --release --warning-mode=all
Checking Java JDK and Android SDK versions
ANDROID_HOME=C:\Users\Maksim\AppData\Local\Android\Sdk (recommended setting)
ANDROID_SDK_ROOT=C:\Users\Maksim\AppData\Local\Android\Sdk (DEPRECATED)
Using Android SDK: C:\Users\Maksim\AppData\Local\Android\Sdk
Subproject Path: CordovaLib
Subproject Path: app
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'lmschat.1t'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:7.4.2.
Required by:
project :
> No matching variant of com.android.tools.build:gradle:7.4.2 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6' but:
- Variant 'apiElements' capability com.android.tools.build:gradle:7.4.2 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
- Variant 'javadocElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
- Variant 'runtimeElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
- Variant 'sourcesElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
* 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.6/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2s
Command failed with exit code 1: C:\Users\Maksim\Desktop\lmschat-mobile\src-cordova\platforms\android\gradlew -b C:\Users\Maksim\Desktop\lmschat-mobile\src-cordova\platforms\android\build.gradle :app:bundleRelease
然后我将Java版本升级到11以实现兼容性(https://docs.gradle.org/current/userguide/compatibility.html),更改系统变量路径,但在执行“cordova requirements”时,我得到了以下结果:
PS C:\Users\Maksim\Desktop\lmschat-mobile\src-cordova> cordova requirements
Requirements check results for android:
Java JDK: installed 11.0.18
Android SDK: installed true
Android target: not installed
Command failed with exit code 1: avdmanager list target
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.AvdManagerCli.run(AvdManagerCli.java:213)
at com.android.sdklib.tool.AvdManagerCli.main(AvdManagerCli.java:200)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 5 more
Gradle: installed C:\Program Files\Gradle\gradle-4.10.3\bin\gradle.BAT
Some of requirements check failed
我做错了什么?
运行“cordova build --release --warning-mode=all”后,应生成一个APK文件。
2条答案
按热度按时间p5cysglq1#
我目前正在使用Linux,并有完全相同的问题,在挠头和阅读了很多关于它的帖子没有任何解决方案后,意识到这一点。
我在操作系统上使用指向openjdk-8-jre的JAVA_HOME路径。但Android Studio默认使用自己的JAVA_HOME路径。
在我的例子中,我将安装程序解压到/opt中,因此Android Studio文件夹的路径是/opt/android-studio,默认情况下(如前所述),Android Studio指向(在我的例子中)/opt/android-studio/jbr。因此,对我来说,将JAVA_HOME的值更改为上述路径解决了这个问题。
运行命令后,这将照顾Gradle和其他一切,甚至从系统中删除openjdk,它就像它应该工作。
我认为这种变化也适用于Windows。
vof42yt12#
我尝试使用Capacitor(quasar.dev/quasar-cli-vite/developing-capacitor-apps/.),在不更改配置文件的情况下,我能够无错误地构建