Cordova Android构建失败

时间:2018-04-26 21:49:57

标签: android cordova

按照https://cordova.apache.org/#getstarted

的说明,我启动了一个新的Cordova项目

当我运行cordova build android --verbose时,我得到以下输出:

No scripts found for hook "before_build". No scripts found for hook "before_prepare". Checking config.xml and package.json for saved platforms that haven't been added to the project Config.xml and package.json platforms are the same. No pkg.json modification. Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms. PlatformApi successfully found for platform android Android Studio project detected Checking config.xml for saved plugins that haven't been added to the project Checking for any plugins added to the project that have not been installed in android platform No differences found between plugins added to project and installed in android platform. Continuing... Generating platform-specific config.xml from defaults for android at /Users/ben.carpenter/code/cordovatest/platforms/android/app/src/main/res/xml/config.xml Merging project's config.xml into platform-specific android config.xml Merging and updating files from [www, platforms/android/platform_www] to platforms/android/app/src/main/assets/www Wrote out android application name "HelloCordova" to /Users/ben.carpenter/code/cordovatest/platforms/android/app/src/main/res/values/strings.xml android-versionCode not found in config.xml. Generating a code based on version in config.xml (1.0.0): 10000 Wrote out Android package name "io.cordova.hellocordova" to /Users/ben.carpenter/code/cordovatest/platforms/android/app/src/main/java/io/cordova/hellocordova/MainActivity.java This app does not have launcher icons defined This app does not have splash screens defined This app does not have additional resource files defined Prepared android project successfully No scripts found for hook "after_prepare". No scripts found for hook "before_compile". ANDROID_HOME=/Users/ben.carpenter/Library/Android/sdk JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home (node:6593) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): [object Object] (node:6593) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejectionsthat are not handled will terminate the Node.js process with a non-zero exit code.

当我运行cordova requirements android时,我得到了这个:

``` 检测到Android Studio项目

android的要求检查结果: Java JDK:已安装 Android SDK:安装为true Android目标:未安装 avdmanager:命令失败,退出代码1错误输出: 线程" main"中的例外情况java.lang.NoClassDefFoundError:javax / xml / bind / annotation / XmlSchema         在com.android.repository.api.SchemaModule $ SchemaModuleVersion。(SchemaModule.java:156)         在com.android.repository.api.SchemaModule。(SchemaModule.java:75)         在com.android.sdklib.repository.AndroidSdkHandler。(AndroidSdkHandler.java:81)         在com.android.sdklib.tool.AvdManagerCli.run(AvdManagerCli.java:213)         在com.android.sdklib.tool.AvdManagerCli.main(AvdManagerCli.java:200) 引起:java.lang.ClassNotFoundException:javax.xml.bind.annotation.XmlSchema         在java.base / jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)         at java.base / jdk.internal.loader.ClassLoaders $ AppClassLoader.loadClass(ClassLoaders.java:190)         at java.base / java.lang.ClassLoader.loadClass(ClassLoader.java:499)         ......还有5个 Gradle:已安装/usr/local/Cellar/gradle/4.7/bin/gradle (node:6724)UnhandledPromiseRejectionWarning:未处理的promise promise(拒绝id:1):[object Object] (节点:6724)[DEP0018]弃用警告:不推荐使用未处理的拒绝承诺。将来,未处理的promise promise将使用非零退出代码终止Node.js进程。 ```

我尝试过安装各种Android SDK平台,我已经尝试过Android studio 2.3和3.1。我已经在这里以及科尔多瓦和离子论坛上阅读了各种各样的问题,但到目前为止没有任何帮助。

2 个答案:

答案 0 :(得分:0)

为什么使用 Java 10 ?我了解Cordova需要JDK 8,因此请尝试安装该版本,然后相应地更新JAVA_HOME

答案 1 :(得分:0)

您的JDK版本似乎存在一些问题。尝试安装JDK 8并更新您的JAVA_HOME路径。