ionic build android error - android

I'm very new to the ionic framework,how ever I've cordova up and running in the windows 7 system but now I'm trying to build an android app with ionic framework and i followed the following steps
>npm install -g cordova
>npm install -g ionic
>ionic start resistance blank
>cd resistance
>ionic platform add android
Till here I'm doing good but when I run the command
>ionic build android
i get the following error
C:\Users\vishwant\resistance>ionic build android
Running command: "C:\Program Files\nodejs\node.exe" C:\Users\vishwant\resistance\hooks\after_prepare\010_add_platform_class.js C:\Users\vishwant\resis
tance
add to body class: platform-android
Running command: C:\Users\vishwant\resistance\platforms\android\cordova\build.bat
C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
Error: ENOENT, no such file or directory 'C:\adt-bundle-windows-x86_64-20140702\sdk\tools\tools\lib\build.template'
at Object.fs.openSync (fs.js:432:18)
at Object.fs.readFileSync (fs.js:289:15)
at C:\Users\vishwant\resistance\platforms\android\cordova\lib\build.js:120:40
at _fulfilled (C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:798:54)
at self.promiseDispatch.done (C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:827:30)
at Promise.promise.promiseDispatch (C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:760:13)
at C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:574:44
at flush (C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:108:17)
at process._tickCallback (node.js:419:13)
Error: C:\Users\vishwant\resistance\platforms\android\cordova\build.bat: Command failed with exit code 8
at ChildProcess.whenDone (C:\Users\vishwant\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
I notice that the path is incorrect , but in the path variable I've set up correctly i.e till tools.
Error: ENOENT, no such file or directory
'C:\adt-bundle-windows-x86_64-20140702\sdk\tools\tools\lib\build.template'
Firstly,I don't understand why it's attaching one more tools\ and searching for the build.template
Secondly, If i manual create that extra tools\ folder inside the tools\ (which i want to avoid) then this above error is gone but i will be shown
C:\Users\vishwant\resistance>ionic build android
Running command: "C:\Program Files\nodejs\node.exe" C:\Users\vishwant\resistance\hooks\after_prepare\010_add_platform_class.js C:\Users\vishwant\resis
tance
add to body class: platform-android
Running command: C:\Users\vishwant\resistance\platforms\android\cordova\build.bat
[Error: Please install Android target "android-19".
Hint: Run "android" from your command-line to open the SDK manager.]
Error: C:\Users\vishwant\resistance\platforms\android\cordova\build.bat: Command failed with exit code 2
at ChildProcess.whenDone (C:\Users\vishwant\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
Since I've already installed android sdks and the targets 4.4W which is working fine for the cordova projects, I don't understand why it's failing for the ionic framework.
Please correct me If I'm missing out something.
Thanks

I guess it's because you set ANDROID_HOME to the wrong path.
ANDROID_HOME must be set to the root of the android SDK, not to tools folder:
SET ANDROID_HOME=C:\adt-bundle-windows-x86_64-20140702\sdk
But the tools folder must be in the path.
SET PATH=%PATH%;%ANDROID_HOME%\tools
(of course use windows settings to set env vars, don't do it in cmd, that was just to explain more clearly)

For Mac OSX users: you can modify your bashprofile
~ nano .bash_profile
Then add the following lines to the file and save it
export ANDROID_HOME=/usr/local/<path_to_your_androidsdk>/
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Reboot your system and run a build
ionic build android
Took me some time to figure that out, hope it helps

Earlier it was
export PATH=$PATH:$ANDROID_HOME/bin
Now it's
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
hope it helps :)

Make sure your android sdk path is set correctly.
Here is the way to set using command prompt then restart it:
SET ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
SET PATH=%PATH%;%ANDROID_HOME%\tools
or you can set it from system setting page.

Related

Keep getting: Failed to install 'cordova-plugin-whitelist':Error: cmd: Command failed with exit code 1

I'm new to this and I just wanted to do the things in this Tutorial:
Installing Cordova & Android SDK on Windows 7, 8 & 10 to Develop Mobile app
At 7:36 it's shown that I have to type:cordova platform add android
I did it but I'm getting this:
Failed to install 'cordova-plugin-whitelist':Error: cmd: Command failed with exit code 1
at ChildProcess.whenDone (G:\Cordovatest\hello\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:829:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
Failed to restore plugin "cordova-plugin-whitelist" from config.xml. You might need to try adding it again. Error: Error: cmd: Command failed with exit code 1
Hope to get some help-
please do the following:
1) Add the environment variables, ANDROID_HOME and JAVA_HOME ( giving the path of the folder Android SDK and the one of JDK in the value).
2) In the System Variable PATH, add the path of the platform-tools the one of the Tools folder.
It will fix your error successfully.
Case Ionic Solution plugin fail whitelisterror
invoking the location of the java_home executable ie java.exe then recompiling
reason: the environment variables did not load at that time fail windows, because if they were well declare, Thanks

PhoneGap Cordova Build Error Exit Code 2

I'minstalled PhoneGap and made one simple app that works on my tablet when using PhoneGap server and PhoneGap App for android. Now I want to makean APK but I'm gatting error when runsudo phonegap build android in APP folder:
miljan#Miljan-PC:~/Desktop/HelloWorld$ sudo phonegap build android
[sudo] password for miljan: [phonegap] executing 'cordova build
android'... cp: no such file or directory:
/home/miljan/Desktop/HelloWorld/icon.png
Running command:
/home/miljan/Desktop/HelloWorld/platforms/android/cordova/build
[Error: ANDROID_HOME is not set and "android" command not in your
PATH. You must fulfill at least one of these conditions.]
ERROR building one of the platforms: Error:
/home/miljan/Desktop/HelloWorld/platforms/android/cordova/build:
Command failed with exit code 2 You may not have the required
environment or OS to build this project
Error:
/home/miljan/Desktop/HelloWorld/platforms/android/cordova/build:
Command failed with exit code 2
at ChildProcess.whenDone (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134: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)
In ~/.profile I have add this:
export ANDROID_HOME=/home/miljan/Android-SDK-Linux
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platforms-tools
How I can slove this problem?
Anyone who can help?
I had the same problem when I was using ionic to build android. I used this solution to solve my problem
Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
use the third solution and don't use the exact paths which are given here. In the android_home give the path of your sdk. in the android_tools give the path of tools in the sdk and in the third give the platform path given in the sdk.
and if you have problem after this too userchmod 777 /sdk/tools and chmod 777 /sdk/tools/android.
May this solution helps

cordova build android throws error on Ubuntu 12.04

The issue looks very familiar with this
Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
But I am not able to fix it. When I run
% sudo cordova build android
I am getting the following error
Running command: /home/thabung/mobile/hello/platforms/android/cordova/build
[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
ERROR building one of the platforms: Error: /home/thabung/mobile/hello/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/thabung/mobile/hello/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
Few things I am observing
% echo $ANDROID_HOME
returns me
~/mobile/android-sdk-linux
which is perfect location
& android command also works fine.
Please help..
I am using cordova 4.3.0
This ...
sudo cordova build android
runs in the environment of root whereas this ...
echo $ANDROID_HOME
was not executed as root. Check what echo $ANDROID_HOME returns as root - or (strongly recommended) - run Cordova as another user than root.
p.s.: I'm running Cordova 4.0.0 on Ubuntu 14.04 without sudo.

Cordova build issue in ubuntu

I was following the tutorials # http://www.gaggl.com/2014/04/apache-cordova-development-environment-install-on-ubuntu/
Cordova build is failing with message:
:~/projects/Hello$ sudo cordova build
Running command: /home/skn/projects/Hello/platforms/android/cordova/build
[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
ERROR building one of the platforms: Error: /home/skn/projects/Hello/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/skn/projects/Hello/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
I have included the android in the path variable also.
skn#bangre:~/projects/Hello$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/bin/java:/usr/bin/ant:.:/home/skn/android-sdk-linux/tools:/home/skn/android-sdk-linux/platform-tools
From screenshot below you can see the sdk is installed
Also I have the following check which is passing.
skn#bangre:~/.cordova/lib/npm_cache/cordova-android/3.7.1/package/bin$ ./android_sdk_version
21
skn#bangre:~/.cordova/lib/npm_cache/cordova-android/3.7.1/package/bin$ ./check_reqs
Looks like your environment fully supports cordova-android development!
Please help me point out the issue.
yes turns out the cordova node.js scripts assumes the android sdk directory name as 'android-sdk' , for ubuntu when we unzip we get 'android-linux-sdk'

PhoneGap install on Mac

I'm getting a bit annoyed at this install. I've followed the instructions from here and I've got as far as adding Android as a platform, the large chunk of code is a copy and paste from my Terminal when I am trying to run it. I have Android SDK installed at ~/Development/sdk/ ~ is the home directory for the user
Donalds-MacBook-Air:hello donaldsutherland$ cordova platform add android
Creating android project...
/Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:126
throw e;
^
Error: The command "android" failed. Make sure you have the latest Android SDK installed, and the "android" command (inside the tools/ folder) is added to your path.
at /Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:85:29
at _rejected (/Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
at /Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
at Promise.when (/Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
at /Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
at flush (/Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
Error: /Users/donaldsutherland/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/src/superspawn.js:126:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)
Donalds-MacBook-Air:hello donaldsutherland$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/your-path/android-sdk-linux/platform-tools:/your-path/android-sdk-linux/tools:/Development/android-sdk-linux/platform-tools:/Development/android-sdk-linux/tools:/Development/sdk/platform-tools:/Development/sdk/tools
Donalds-MacBook-Air:hello donaldsutherland$
If I run $ cordova platforms ls it lists Available platforms: amazon-fireos, android, blackberry10, firefoxos, ios
create a a profile file ~/.bash_profile
write this line to add the android SDK folder to your PATH
export PATH=${PATH}:~/Development/sdk/tools:~/Development/sdk/platform-tools
close the terminal and open it again, then it should recognize the "android" command everywhere

Categories

Resources