离子3 cli&ion cordova运行android'命令抛出错误

时间:2017-05-10 18:25:52

标签: android cordova ionic-framework ionic2 ionic3

我将cli更新为离子3版本,当我运行时

  

离子cordova运行android

构建apk文件并在android模拟器中运行我收到此错误

    C:\Users\XXXX\Desktop\beep>ionic cordova run android
Running app-scripts build: --address 0.0.0.0 --port 8100 --p 8100 --livereload-port 35729 --r 35729 --iscordovaserve --externalIpRequired --nobrowser

[20:52:20]  build dev started ...
[20:52:20]  clean started ...
[20:52:20]  clean finished in 11 ms
[20:52:20]  copy started ...
[20:52:20]  transpile started ...
[20:52:22]  transpile finished in 2.53 s
[20:52:22]  preprocess started ...
[20:52:22]  deeplinks started ...
[20:52:23]  deeplinks finished in 52 ms
[20:52:23]  preprocess finished in 54 ms
[20:52:23]  webpack started ...
[20:52:23]  copy finished in 2.77 s
[20:52:31]  webpack finished in 8.53 s
[20:52:31]  sass started ...
[20:52:32]  sass finished in 1.11 s
[20:52:32]  postprocess started ...
[20:52:32]  postprocess finished in 7 ms
[20:52:32]  lint started ...
[20:52:32]  build dev finished in 12.29 s
> cordova run android
ANDROID_HOME=C:\Users\XXXX\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_101
Error: Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio


[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova run android (exit code 1).

我已经尝试过做的事情并没有帮助:  1.删​​除android studio并重新安装。  2.运行这些命令

cordova platform rm android
cordova platform add android
npm cache clear
  1. 更新android studio中的sdk
  2. 没有什么能真正帮助解决这个问题。

5 个答案:

答案 0 :(得分:8)

对我来说,这解决了这个问题:

ionic cordova platform rm android 
ionic cordova platform add android 

答案 1 :(得分:2)

将Android Studio的Gradle(例如,/usr/local/android-studio/gradle/gradle-3.2/bin for linux)的位置添加到PATH环境变量

答案 2 :(得分:2)

我是如何解决这个问题的。

  1. 下载gradle最新版本bin文件此链接link to download gradle

  2. 将winzip文件解压缩到java文件夹中(例如C:\ Program Files \ Java \ jdk1.8.0_101 \ gradle-3.5)

  3. 右键点击我的电脑 - >属性。
  4. 然后转到左侧菜单中的高级系统设置。
  5. 进展 - >环境变量然后选择路径。
  6. 添加名为%GRADLE_HOME%/ bin
  7. 的新环境变量

答案 3 :(得分:1)

我也面临同样的问题,现在解决了以下步骤

的问题
  1. 下载了gradle zip版本并解压缩到路径user\<username>\android-sdk\gradle

  2. 环境变量中配置的相同路径,例如GRADLE_HOMEpath

答案 4 :(得分:-2)

我遇到了同样的问题,请运行以下命令它应该可以正常工作。

离子cordova运行android --livereload