在对Android Studio和Apache Cordova进行一些更新后,我的Apache Cordova项目尚未构建。
我是Apache Cordova,OS X和Android Studio的新手。
在我重建项目的Android Studio中,我在Gradle控制台中收到以下错误。
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
在终端中,当我运行命令cordova --version
时,它打印出4.0.0
并且which javac
打印出/usr/bin/javac
但是回显$ JAVA_HOME不打印任何内容(空行)。 / p>
更新:我在终端中设置JAVA_HOME和ANDROID_HOME的路径,即使我得到如下所示的相同错误,在关闭终端后JAVA_HOME和ANDROID_HOME环境变量丢失,我将它们设置为{{ 1}}和export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home
当我尝试从Cordova CLI构建项目时,它也无法正常工作。
我收到以下错误,就好像我在gradle-wrapper.properties中更改distributionUrl并将buildToolsVersion从“19.0.0”更改为“19.1.0”之后创建了一个新项目,新项目运行正常。 / p>
请帮忙。
cordova编译命令
export ANDROID_HOME=/Users/apple/Library/Android/sdk
cordova build命令
Sreekanth-2:19:02:16 Sreekanth$ cordova compile
Running command: "/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/cordova/build"
Buildfile: /Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/build.xml
BUILD FAILED
/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/build.xml:7: The following error occurred while executing this line:
java.io.FileNotFoundException: /Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:/usr/local/Cellar/ant/1.9.7/libexec/lib/ant.jar (No such file or directory)
at java.io.RandomAccessFile.open0(Native Method)
at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
at org.apache.tools.zip.ZipFile.<init>(ZipFile.java:212)
at org.apache.tools.zip.ZipFile.<init>(ZipFile.java:177)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:256)
at org.apache.tools.ant.helper.ProjectHelper2.parseUnknownElement(ProjectHelper2.java:131)
at org.apache.tools.ant.helper.ProjectHelper2.parseAntlibDescriptor(ProjectHelper2.java:111)
at org.apache.tools.ant.taskdefs.Antlib.createAntlib(Antlib.java:94)
at org.apache.tools.ant.taskdefs.Definer.loadAntlib(Definer.java:425)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:277)
at org.apache.tools.ant.ComponentHelper.checkNamespace(ComponentHelper.java:874)
at org.apache.tools.ant.ComponentHelper.getDefinition(ComponentHelper.java:307)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:284)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:263)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:430)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:164)
at org.apache.tools.ant.Task.perform(Task.java:347)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:180)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
at org.apache.tools.ant.Main.runBuild(Main.java:829)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Total time: 0 seconds
/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: ant with args: debug,-f,/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: /Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
答案 0 :(得分:0)
转到Project.Properties
添加以下几行
cordova.system.library.1=com.google.android.gms:play-services-auth:9.8.0
cordova.system.library.2=com.google.android.gms:play-services-identity:9.8.0
再次运行cordova命令,您可以构建发行版并调试构建版本
答案 1 :(得分:-1)
在终端中输入以下内容
echo&#34;导出JAVA_HOME = /usr/libexec/java_home
&#34;
这将打印Java_home的确切导出,复制并粘贴到终端并按Enter键。
然后尝试echo $ java_home。