I am new to Ionic and created a simple application. I have installed Android Sdk. And added these Environment Variable
I am trying to build my app using cordova build commandcommand but getting this error :-
Error: cmd: Command failed with exit code ENOENT
I am been searching whole day for the solution and finally ended up here.
For linux, you'll also need to add these lines in ~/.bashrc file
export ANDROID_HOME='/home/your_username/Android/Sdk'
export ANDROID_SDK_ROOT='/home/your_username/Android/Sdk'
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin
Then check if android target is read with cordova requirements first.
Reference for Mac OS:
https://gist.github.com/kristopherjohnson/7568583
Command should be ionic platform add android and not cordova platform add android
I was getting the same error ...
In my case, it was occurring because of the changes in ionic CLI...
Now you need to run 'ionic cordova platform add android' (or ios) but the extension dont run this command yet...
I just insert 'cordova' in the source code of plugin (try to search the funcions that run the commands that start with 'ionic' and have to run 'cordova' together'
In the macOS, you find the source code at:
~/.vscode/extensions/vsmobile.cordova-tools-1.2.7/out/src/debugger/cordovaDebugAdapter.js
In the Windows, the path is:
C:\Users\yourusername\.vscode\extensions\vsmobile.cordova-tools-1.2.7\out\src\debugger\cordovaDebugAdapter.js
It worked for me...
Related
I am building an app using ionic framework.
when I execute the command 'ionic build android' it is showing the following message.
C:\Windows\System32\todo>ionic build android
Running command: "C:\Program Files\nodejs\node.exe" C:\Windows\System32\todo\hooks\after_prepare\010_add_platform_class.js C:\Windows\System32\todo
add to body class: platform-android
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk\
JAVA_HOME=C:\Program Files\java\jdk1.8.0_66
Error: spawn cmd ENOENT
I am running it on a windows 7 system using node.js command prompt
I have googled, but couldn't find any helpful solution.
Plese help. Thanks in advance
This issue may be due to your are not set current path of npm(C:\Users\\AppData\Roaming\npm) in environment variable.
On some systems, it was the problem of access:
Android Studio 3.0 removes the execute permission from Gradle, breaking the build
you can change the permissions and check the result!
The problem may come from windows services. Windows child process services not running properly.
In windows, OS => Go to System Config and enable all services and restart the computer. For more details check here.
Maybe it can help you on build error with ionic/cordova error with android platform on windows
After install ant/ionic with :
%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\build-tools
start a new projet : ionic start hello blank ->ok
ionic platform add android -> ok
ionic build android - Error:
BUILD FAILED
C:\SDK\android-sdk\tools\ant\build.xml:954: The following error occurred while executing this line:
C:\SDK\android-sdk\tools\ant\build.xml:971: null returned: -1073741819
Total time: 2 seconds
D:\PROD\myapp\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,D:\PROD\myapp\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
ERROR building one of the platforms: Error: D:\PROD\myapp\platforms\android\cordova\build.bat: Command failed with exit code 8
You may not have the required environment or OS to build this project
Paths are OK and if I start a new cordova projet (not ionic) build is a success.
If I check problem on c:\android-sdk\build.xml and I add
<echo>aapt: ${aapt}</echo>
I can see aapt.exe path is on android-21 (target is android-19)
For me, problem is I have two android sdk : android 19 and android 21. If I use CLI on windows, ionic/cordova choose android-21\aapt.exe by default and no android-19\aapt.exe
I tried to force Path with android version : %ANDROID_HOME%\build-tools\19.0.0 with no success.
To resolve this problem I changed paths to force on aapt executable path to point on android 19:
File c:\android-sdk\tools\ant\build.xml :
<aapt executable="C:\android-sdk\build-tools\19.0.0\aapt.exe" ...
</aapt>
This is not the best way, but I have not found another.
Instruction 1:
After adding your ANDROID_HOME, make sure you do the below:
Restart your System or run source ~/.bash_profile
Remove Android platform from your project ionic cordova platform rm android or ionic platform rm android
Add Android platform ionic cordova platform add android
Then ionic cordova run android or ionic run android
Instruction 2:
To set your ANDROID_HOME and JAVA_HOME, follow the below steps:
Run command open ~/.bash_profile
Paste the below in the file that opens on your Text editor
export ANDROID_HOME=/usr/local/Cellar/android-sdk/24.4.1_1
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Save - "Command S" or "Ctrl S"
Then Follow the "Instruction 1:" above
NOTE: Make sure you have **24.4.1_1 SDK**
Hope this helps.
I was trying to get started on this demo for ionic on a mac OSX
http://ionicframework.com/docs/guide/installation.html
and I got to the point where I was supposed to add platforms so I entered this command in my terminal:
ionic platform add android
but then I got these errors:
Error: ENOENT, no such file or directory '/Users/adeyo/todo/ionic-app-base-master/plugins/android.json'
at Error (native)
at Object.fs.openSync (fs.js:455:18)
at Object.fs.writeFileSync (fs.js:1001:15)
at Object.save_platform_json (/usr/local/etc/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/config-changes.js:476:8)
at PlatformMunger_process [as process] (/usr/local/etc/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/config-changes.js:401:13)
at Object.exports.process (/usr/local/etc/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/config-changes.js:80:12)
at Object.handlePrepare (/usr/local/etc/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/prepare.js:72:20)
at /usr/local/etc/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/prepare.js:102:25
at Array.map (native)
at /usr/local/etc/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/prepare.js:66:40
I get a similar error when I try to add an ios platform and I have no Idea how to fix this.
Creating the folder plus installing ant worked for me:
mkdir plugins
brew install ant
I just had to make the directory. I already had ant installed.
Be sure that your current work directory in cmd are in your project, in my case i was at it's parent by mistake and try to add platform
Try to update ionic by: npm install -g ionic
I installed cordova e phonegap via npm install -g cordova and npm install -g phonegap respectively. Then i created a HelloWorld application via cordova create HelloWorld mynamespace.helloworld HelloWorld. It worked fine! Then i changed my working directory to HelloWorld and i tried to build the app for android via cordova platform add android -d but it didn't work. here is the output:
Installing cordova library for android...
Requesting {"uri":"https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=snapshot;h=3.3.0;sf=tgz"}...
Downloading cordova library for android...
Downloaded, unzipped and extracted 541065 byte response.
Download complete
Installing cordova library for android...
Checking if platform "android" passes minimum requirements...
Creating android project...
Running bin/create for platform "android" with command: ""C:\Users\marcos.pacheco\.cordova\lib\android\cordova\3.3.0\bin\create" "C:\Dev\HelloWorld\platforms\android" "mynamespace.helloworld" "HelloWorld"" (output to follow)
C:\Users\marcos.pacheco\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:126
throw e;
^
Error: An error occured during creation of android sub-project.
at C:\Users\marcos.pacheco\AppData\Roaming\npm\node_modules\cordova\src\platform.js:244:30
at exithandler (child_process.js:633:7)
at ChildProcess.errorhandler (child_process.js:649:5)
at ChildProcess.EventEmitter.emit (events.js:95:17)
at Process.ChildProcess._handle.onexit (child_process.js:787:12)
I've googled and have found some issues with whitespaces but my project is in the C:\Dev\HelloWorld path and my android sdk is in the PATH so that when i type adb at the windows prompt i get the help information of the command as well Java and Ant. Furthermore, i have ANT_HOME, JAVA_HOME and ANDROID_HOME set. I also deleted the ** .cordova ** folder inside my %HOMEPATH% directory and entered the command again but the error is still there.
What might be wrong?
XCOPY needs to be defined and found on your path as it is used by the internal node.js scripts to move things around.
You probably already have xcopy.exe somewhere on your machine. You should be able to add %SystemRoot%\System32 to your PATH and it will work. Or you can open up a terminal and type where xcopy to see the actual path to your xcopy.exe.
I guess having XCOPY on the path is a requirement for setting up and installing Android, but it'd be nice if Cordova checked to make sure you have XCOPY somewhere...
I followed the documentation and some tutorials on Phonegap to install it on Windows 7, but I'm stuck.
So far, I've installed Java 1.7.0_06, Ant-Apache 1.9.2, Eclipse, Android SDK with Android 4.3 (API 18), all Tools and all Extras in the SDK Manager), NodeJS 0.10.18 and Git.
I wrote all paths in the PATH variables in Windows it's look like this (decomposed) :
F:\nodejs;
F:\android-sdk\sdk\platform-tools;
F:\android-sdk\sdk\tools;
%JAVA_HOME%\bin;
%ANT_HOME%\bin;
C:\Program Files (x86)\Git\bin
Where %JAVA_HOME% and %ANT_HOME% have the right path, they give me the their version when I type java -version or ant -version in the CLI
So I went in the CLI, I installed Phonegap with the following command :
npm install -g phonegap
It give me the 3.0.0-0.14.3 version when I type phonegap -v.
Now, I went to my folder F:\apps and I created a new project with the following command :
phonegap create hello com.example.hello HelloWorld
Everything goes well, the files are created.
I went in the 'hello' folder, and I typed this command :
phonegap local build android
And there come the problem, I get this error :
[phonegap] adding the Android platform...
[error] The command `android` failed. Make sure you have the latest AndroidSDK installed, and the `android` command (inside the tools/ folder) added to your path. Output:
I tried this command too :
phonegap build android
But it get stuck at this, nothing happen next :
[phonegap] detecting Android SDK environment...
[phonegap] using the remote environment
[phonegap] compressing the app...
After lot's of research, I don't know what I can do anymore to find the problem, and I'm quiet new with all this CLI... So yeah, do you have any idea why the command 'android' failed ?
Thanks
Open environment variables, on the first part 'user variables' add new variable with this name android and the variable F:\android-sdk\sdk\tools;
Then edit the user variables PATH and add this at end of the line %android%;
close your CMD and try again.