简体   繁体   English

无法使用Gradle构建Ionic / Cordova Android项目

[英]Can't build Ionic/Cordova Android project using Gradle

I'm trying out ionic for the first time. 我是第一次尝试离子性。 I have no issues with iOS, but building the demo app for Android gives me an error with virtually no information (see below). 我在iOS上没有任何问题,但是为Android构建演示应用程序给我一个错误,几乎没有任何信息(请参阅下文)。 It seems likely to me that the issue is with the gradle config file that ships with Cordova, but I don't believe it's considered good practice with Cordova to edit the platform-specific files if you can avoid it. 在我看来,问题可能出在Cordova附带的gradle配置文件上,但是我认为如果可以避免的话,Cordova编辑平台特定的文件被认为是一种好习惯。

[myApp]Bro? ionic build android
Running command: /Users/x/Documents/Dev/myApp/hooks/after_prepare/010_add_platform_class.js /Users/x/Documents/Dev/myApp
add to body class: platform-android
Running command: /Users/x/Documents/Dev/myApp/platforms/android/cordova/build 
ANDROID_HOME=/Users/x/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home
Running: /Users/x/Documents/Dev/myApp/platforms/android/gradlew cdvBuildDebug -b /Users/x/Documents/Dev/myApp/platforms/android/build.gradle -Dorg.gradle.daemon=true

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> A problem occurred configuring project ':CordovaLib'.
   > Failed to notify project evaluation listener.
      > java.lang.ExceptionInInitializerError (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Looked at the stacktrace and it was clear that I had an issue with my Java XPath and XQuery libraries (Saxon). 看一下堆栈跟踪,很明显我的Java XPath和XQuery库(Saxon)有问题。 Turns out I hadn't updated that library since migrating from JDK 7 to JDK 8, and JDK 8 is not compatible with the version I had installed. 事实证明,自从JDK 7迁移到JDK 8以来,我还没有更新该库,而且JDK 8与我安装的版本不兼容。 Looks like the Android build uses the same plugin to parse the AndroidManifest.xml. 看起来Android构建使用相同的插件来解析AndroidManifest.xml。

Short answer - look at your stack trace. 简短的答案-查看您的堆栈跟踪。 Perhaps it also has to do with an outdated Java library. 也许这也与过时的Java库有关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM