Невозможно создать и запустить приложение на базе ионных и кордовых устройств на Android - PullRequest
0 голосов
/ 21 сентября 2018

У меня есть очень простое Ionic приложение, которое я пытаюсь собрать и запустить на Win 10 машине.Но я получаю следующую ошибку при запуске этой команды.Не уверен, что еще не хватает, так как я совсем новичок в технологиях NodeJS и Android.

# ionic cordova build android
> ionic-app-scripts build --target cordova --platform android
[16:57:21]  ionic-app-scripts 3.2.0
[16:57:21]  build dev started ...
[16:57:21]  clean started ...
[16:57:21]  clean finished in 21 ms
[16:57:21]  copy started ...
[16:57:21]  deeplinks started ...
[16:57:21]  deeplinks finished in 26 ms
[16:57:21]  transpile started ...
[16:57:23]  transpile finished in 2.77 s
[16:57:23]  preprocess started ...
[16:57:23]  preprocess finished in 1 ms
[16:57:23]  webpack started ...
[16:57:24]  copy finished in 2.94 s
[16:57:26]  webpack finished in 2.57 s
[16:57:26]  sass started ...
[16:57:27]  sass finished in 913 ms
[16:57:27]  postprocess started ...
[16:57:27]  postprocess finished in 10 ms
[16:57:27]  lint started ...
[16:57:27]  build dev finished in 6.43 s
[16:57:29]  lint finished in 2.17 s
> cordova build android
Android Studio project detected
ANDROID_HOME=C:\Program Files\Android\Android Studio
JAVA_HOME=C:\Java\jdk
studio
Subproject Path: CordovaLib
Subproject Path: app

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\nital\Documents\Tech\RESET-CODE-SAMPLES\IONIC-CODE-SAMPLES\ionic-basics\platforms\android\CordovaLib\cordova.gradle' line: 68

* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> No installed build tools found. Install the Android build tools version 19.1.0 or higher.

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

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
(node:15236) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\nital\Documents\Tech\RESET-CODE-SAMPLES\IONIC-CODE-SAMPLES\ionic-basics\platforms\android\CordovaLib\cordova.gradle' line: 68

* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> No installed build tools found. Install the Android build tools version 19.1.0 or higher.

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

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
    at ChildProcess.whenDone (C:\Users\nital\Documents\Tech\RESET-CODE-SAMPLES\IONIC-CODE-SAMPLES\ionic-basics\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:961:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:250:5)
(node:15236) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:15236) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Ионная информация

# ionic info
√ Gathering environment info - done!

Ionic:

   ionic (Ionic CLI)  : 4.1.2 (C:\Users\nital\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.0

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.1.4, (and 4 other plugins)

System:

   NodeJS : v10.9.0 (C:\Program Files\nodejs\node.exe)
   npm    : 6.2.0
   OS     : Windows 10

Требования Cordova:

# cordova requirements
Android Studio project detected

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed
cmd: Command failed with exit code 1 Error output:
'android' is not recognized as an internal or external command,
operable program or batch file.
Gradle: installed C:\Program Files\Android\Android Studio\gradle\gradle-4.4\bin\gradle
(node:10252) UnhandledPromiseRejectionWarning: CordovaError: Some of requirements check failed
    at C:\Users\nital\AppData\Roaming\npm\node_modules\cordova\src\cli.js:414:27
    at _fulfilled (C:\Users\nital\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54)
    at C:\Users\nital\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:816:30
    at Promise.promise.promiseDispatch (C:\Users\nital\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:749:13)
    at C:\Users\nital\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:557:44
    at flush (C:\Users\nital\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:108:17)
    at process._tickCallback (internal/process/next_tick.js:61:11)
(node:10252) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:10252) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Переменные среды:

JAVA_HOME = C:\Java\jdk
GRADLE_HOME = C:\Program Files\Android\Android Studio\gradle\gradle-4.4
ANDROID_HOME = C:\Program Files\Android\Android Studio
Path =  %JAVA_HOME%\bin; %GRADLE_HOME%\bin; %ANDROID_HOME%\bin;

Информация о версии Java:

# javac -version
javac 1.8.0_181

# java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

Я также посмотрел эту онлайн-ссылку https://cordova.apache.org/docs/en/latest/guide/platforms/android/ и после установки Android Studio установил все необходимые инструменты и дополнения (скриншот ниже)

enter image description here

enter image description here

Ответы [ 2 ]

0 голосов
/ 21 сентября 2018

Нашли решение.

Итак, здесь возникли две проблемы:

  1. Неверно ANDROID_HOME Значение переменной env.Это не должно указывать на то, где вы установили Android.AppData - это скрытая папка в Win, поэтому вам нужно найти ее, а затем указать правильный путь

    ANDROID_HOME = C: \ Users \ nital \ AppData \ Local \ Android \ Sdk

  2. Не указывает PATH переменную env на папки platform_tools и tools, расположенные в папке Sdk

    PATH = C: \ Users \ nital \ AppData \ Local \ Android \ Sdk \инструменты платформы

    PATH = C: \ Users \ nital \ AppData \ Local \ Android \ Sdk \ tools

0 голосов
/ 21 сентября 2018

Вам не хватает каталога android sdk в вашем пути.

Если вы посмотрите журнал требований Cordova, он говорит: 'android' is not recognized as an internal or external command

Так что вам нужно добавить tools иplatform-tools от того, где Android-SDK установлен в вашем системном пути.

...