离子cordova构建android / cordova.cmd构建android,退出代码为1。错误

时间:2019-09-03 15:33:28

标签: ionic-framework ionic4

可能是问题所在了。但是,“ gradle -v”命令可以在cmd上成功执行并查看gradle版本。但是我单独下载并设置了路径变量以使用gradle。

ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\intern\AppData\Local\Android\Sdk\ (DEPRECATED)

Subproject Path: CordovaLib
Subproject Path: app
Exception in thread "main" java.lang.NullPointerException
        at org.gradle.wrapper.PathAssembler.getDistName(PathAssembler.java:84)
        at org.gradle.wrapper.PathAssembler.getDistribution(PathAssembler.java:40)
        at org.gradle.wrapper.Install.createDist(Install.java:44)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
C:\Users\intern\Desktop\ionic\MyIonicProject\platforms\android\gradlew: Command failed with exit code 1 Error output:
Exception in thread "main" java.lang.NullPointerException
        at org.gradle.wrapper.PathAssembler.getDistName(PathAssembler.java:84)
        at org.gradle.wrapper.PathAssembler.getDistribution(PathAssembler.java:40)
        at org.gradle.wrapper.Install.createDist(Install.java:44)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)

[ERROR]运行子进程cordova时发生错误。

    cordova.cmd build android exited with exit code 1.

2 个答案:

答案 0 :(得分:0)

如果您使用的是Cordova版本> = 7或Android SDK Tools> = 26,则需要手动安装gradle(reference)。在Windows 10上,您可以这样安装gradle:

  1. https://gradle.org/releases/下载二进制发行版
  2. 将其解压缩到您喜欢的任何文件夹,例如C:\gradle
  3. 编辑系统环境变量以包括目录C:\gradle\bingradle.bat所在的目录)

之后,您应该能够正常构建项目。

答案 1 :(得分:0)

您必须安装Gradle

tutorial很适合您

这是Gradle网站