The Android Command for Ionic Framework does not w

2019-04-12 02:24发布

问题:

I am on Windows 8 and following through how to install and use Cordova with Ionic Framework on Windows 8.1. I followed through the video here: http://learn.ionicframework.com/videos/windows-android/. I am stuck at 5:58 of the video where the SDK Manager is suppose to come up when I type 'android' in the command line, but it says it's unrecognizable command. I made sure my file directories are exact. What else am I missing? How do I fix this problem?

PATH
C:\Users\Jaime\AppData\Roaming\npm; C:\Program Files\Java\jdk1.8.0_25\bin; C:\Development\AndroidSDK\sdk\platform-tools; C:\Development\AndroidSDK\sdk\tools; C:\Development\ApacheAnt\bin; C:\Program Files\nodejs

Thanks!


Problem with Android command:

C:\Users\Jaime\myapp>ionic platform add android
npm http GET https://registry.npmjs.org/cordova-android/3.6.4
npm http 200 https://registry.npmjs.org/cordova-android/3.6.4
npm http GET https://registry.npmjs.org/cordova-android/-/cordova-android-3.6.4.
tgz
npm http 200 https://registry.npmjs.org/cordova-android/-/cordova-android-3.6.4.
tgz
Creating android project...

C:\Users\Jaime\.cordova\lib\npm_cache\cordova-android\3.6.4\package\bin\node_mod
ules\q\q.js:126
                    throw e;
                          ^
Error: ANDROID_HOME is not set and "android" command not in your PATH. You must
fulfill at least one of these conditions.
    at C:\Users\Jaime\.cordova\lib\npm_cache\cordova-android\3.6.4\package\bin\l
ib\check_reqs.js:159:19
    at _fulfilled (C:\Users\Jaime\.cordova\lib\npm_cache\cordova-android\3.6.4\p
ackage\bin\node_modules\q\q.js:798:54)
    at self.promiseDispatch.done (C:\Users\Jaime\.cordova\lib\npm_cache\cordova-
android\3.6.4\package\bin\node_modules\q\q.js:827:30)
    at Promise.promise.promiseDispatch (C:\Users\Jaime\.cordova\lib\npm_cache\co
rdova-android\3.6.4\package\bin\node_modules\q\q.js:760:13)
    at C:\Users\Jaime\.cordova\lib\npm_cache\cordova-android\3.6.4\package\bin\n
ode_modules\q\q.js:821:14
    at flush (C:\Users\Jaime\.cordova\lib\npm_cache\cordova-android\3.6.4\packag
e\bin\node_modules\q\q.js:108:17)
    at process._tickCallback (node.js:415:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)
    at node.js:902:3
Error: C:\Users\Jaime\.cordova\lib\npm_cache\cordova-android\3.6.4\package\bin\c
reate.bat: Command failed with exit code 8
    at ChildProcess.whenDone (C:\Users\Jaime\AppData\Roaming\npm\node_modules\co
rdova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Process.ChildProcess._handle.onexit (child_process.js:810:5)

Update:

Here's what I have so far:
USER variables:

name: PATH variable: C:\Users\Jaime\AppData\Roaming\npm; C:\Program Files\Java\jdk1.8.0_25\bin; C:\Development\AndroidSDK\sdk\platform-tools; C:\Development\AndroidSDK\sdk\tools; C:\Development\AndroidSDK\sdk\build-tools; C:\Development\ApacheAnt\bin; C:\Program Files\nodejs; %PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

SYSTEM variables:

name: ANDROID
variable: C:\Development\AndroidSDK\sdk

name: ANT
variable: C:\Development\ApacheAnt

name: JAVA
variable: C:\Program Files\Java\jdk1.8.0_25

回答1:

Phonegap and cordova installation procedures

what are the need for installiation?

1)node js download:http://nodejs.org/download/ We have node-v0.10.29-x64.msi (64 bit) installation. After install, open command prompt & type "node -v" , then "npm -v", these 2 commands should work without any error in command prompt. Open command prompt - (Click windows and R keynd then enter the cmd)

2)phonegap

http://phonegap.com/install/ Install phonegap on cmd: enter npm install -g phonegap on cmd After installation, files will be placed in C:\Users\Hari\AppData\Roaming\npm folder. You can check the installation by typing the command "phonegap -v" in command prompt.

3)java jdk http://www.oracle.com/technetwork/java/javase/downloads/index.html?ssSourceSiteId=otnjp

We have jdk-8u5-windows-x64.exe file.

You may need to add path variables in My computer-->Right click-->Properties-->Advanced system settigs-->Environment variables

After install, check "java -version" in command prompt. "where java" will help you to identify the installation path of the java.

4)ant download:http://ant.apache.org/

We already have apache-ant-1.9.4-bin.zip portable edition of Ant, We need not to install, just need to extract the zip file & place it in some secure place.

You may need to add path variables in My computer-->Right click-->Properties-->Advanced system settigs-->Environment variables Environment variables name:Ant_Home Ex: C:\Program Files\apache-ant-1.9.4

5)android sdk download:http://developer.android.com/sdk/index.html We have adt-bundle-windows-x86_64-20140624/SDK Manager.exe file.

6)ionic cmd-->npm install -g ionic

7)cordova cmd-->npm install -g cordova


PATH SETTING

My computer-->Right click-->Properties-->Advanced system settigs-->Environment variables Edit the Path and give the like this

C:\Users\prabhu\AppData\Roaming\npm;C:\Program Files\apache-ant-1.9.4\bin;C:\phonegap_project\adt-bundle-windows-x86_64-20131030\sdk\tools;C:\phonegap_project\adt-bundle-windows-x86_64-20131030\sdk\build-tools;C:\Program Files\Java\jdk1.8.0_05\bin;

if Not Run JVM
Set systems variables Click New variable Name:_JAVA_OPTIONS variable value:-Xmx512M