PhoneGap install on Mac - android

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

Related

ionic build android error

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.

Issues with cordova and android studio

I have downloaded android studio, installed ant, node.js, cordova and jdk
But I can not add platform to my cordova android app
Here is the bashrc file:
JAVA_HOME=/usr/lib/jvm/jdk1.8.0
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
export PATH=${PATH}:/home/Dev/android-studio/sdk/tools
export PATH=${PATH}:/home/Dev/android-studio/sdk/platform-tools
Whenever I try to add platform under my created app project it throws error:
Creating android project...
/home/anupam/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /home/anupam/.cordova/lib/android/cordova/3.5.1/bin/lib/check_reqs.js:87:29
at _rejected (/home/anupam/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:808:24)
at /home/anupam/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:834:30
at Promise.when (/home/anupam/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/anupam/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:752:41)
at /home/anupam/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:574:44
at flush (/home/anupam/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
Error: /home/anupam/.cordova/lib/android/cordova/3.5.1/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/lib/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 an tired of searching all the answers in stackoverflow and google. Not a single guide could solve my problem. Just one thing I want to use ANdroid studio, not eclipse. SO please do not mention eclipse workarounds. If there is any clean install method , please mention if needed.
I had a similar issue - if you have eclipse installed prior your cordova installation, then you probably don't have the latest API updates.
Run android from your command line to open your SDK Manager - or find it in your android installation root folder (for CLI - Use Administrator) - or simply from your eclipse UI command.
In here find where updates are needed and install and run your android installation as you did before cordova platform add android

cordova phonegap - error installing on Android platform

I am new to Cordova and phonegap but have Android working on my ubuntu 12.04.
I followed this official guide and manage to install cordova.
Despite my machine supports android sdk, when I run this command:
cordova platform add android
I get the following exception:
*cordova platform add android
Creating android project...
/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /root/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:87:29
at _rejected (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
at /root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
at Promise.when (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
at /root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
at flush (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Error: /root/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/src/superspawn.js:112: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)
root#sergio-Aspire-5755G:/home/sergio/Development/HelloWorld# cordova platforms ls
Installed platforms:
Available platforms: android, blackberry10, firefoxos, ubuntu
root#xxx-Aspire-5755G:/home/sergio/Development/HelloWorld# cordova platform add android
Creating android project...
/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /root/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:87:29
at _rejected (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
at /root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
at Promise.when (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
at /root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
at flush (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Error: /root/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/src/superspawn.js:112: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)*
I tried and see other post like this but noone helped me.
Android sdk version 19 is installed
1) run "android avd" command and create at least one virtual device based on a version of a previously downloaded SDK.
2) sudo apt-get install ant1.8
worked for me.
You need to check if path to Android SDK is correct or not. Check your Environment Variables PATH, ANDROID_PLATFORM_TOOLS, ANDROID_HOME, ANT_HOME you can check if they are configured correctly by echo %ANDROID_HOME% check for all Paths you will know which path is not configured properly.
I solved this way:
adding the below line to my .bashrc:
export PATH=$PATH:/opt/adt-bundle-linux-x86_64-20131030/sdk/platform-tools:/opt/adt-bun‌​dle-linux-x86_64-20131030/sdk/tools

Phonegap I can't add android platform to my project

I installed Android SDK and $PATH already. But It can't add android platform to my project.
Help me please.
This is my $PATH
/Users/xxx/Applications/eclipse/sdk/platform-tools:/Users/xxx/Applications/eclipse/sdk/tools:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
This is ERROR when I add android platform to my project
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/xxx/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:85:29
at _rejected (/Users/xxx/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
at /Users/xxx/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
at Promise.when (/Users/xxx/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/Users/xxx/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
at /Users/xxx/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
at flush (/Users/xxx/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Error: /Users/xxx/.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:112:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Process.ChildProcess._handle.onexit (child_process.js:802:5)
Create file .bash_profile and save in your home directory.
Then you copy this script into this file.
export PATH="/Applications/android-sdk/tools:/Applications/android-sdk/platform-tools:$PATH"
Looks like you have missed something,
To check the SDK just open Command Prompt and type in "android" and make sure it opens the SDK manager and check out you have installed the android latest version.
Here is my path and is perfectly configured for phonegap and integrated with eclipse,
C:\Program Files (x86)\nodejs\;
%ANDROID_HOME%\tools;
%ANDROID_HOME%\platform-tools;
C:\Program Files (x86)\Java\jdk1.7.0_03;
C:\Program Files (x86)\Java\jdk1.7.0_03\bin;
%ANT_HOME%\bin;
%ANT_HOME%\lib;
F:\Phonegap\windows_adt\sdk\platform-tools;F:\Phonegap\windows_adt\sdk\tools;
%JAVA_HOME%\bin;
%ANT_HOME%\bin;
C:\Program Files (x86)\Git\bin
Here are the sublinks,
ANDROID_HOME: F:\Phonegap\windows_adt\sdk
ANT_HOME: C:\Program Files (x86)\ANT\apache-ant-1.9.2
JAVA_HOME: C:\Program Files (x86)\Java\jdk1.7.0_03

Cordova add platform error in Ubuntu

I have the android latest sdk tools in my Ubuntu 13.10 x64 Documents folder.The eclipse and sdk are working fine,also created one virtual device.
cd Documents
cd adt-bundle-linux-x86_64-20130514/
cd sdk/
ls -l
It gives me these,
add-ons
build-tools
docs
extras
platforms
platform-tools
samples
sources
system-images
temp
tools
Now installed ant using sudo apt-get install ant
Then edited path,
gedit ~/.bashrc
And added this code at end,
#AndroidDev PATH
export PATH=${PATH}:~/Documents/adt-bundle-linux-x86_64-20130514/sdk/tools
export PATH=${PATH}:~/Documents/adt-bundle-linux-x86_64-20130514/sdk/platform-tools
Now when I tried to add android platform to sample project, it throws error,
cd hello
cordova platform add android
The error,
Creating android project...
/home/######/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /home/######/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:87:29
at _rejected (/home/######/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
at /home/######/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/######/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/######/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
at /home/######/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
at flush (/home/######/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Error: /home/######/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/src/superspawn.js:112: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)
I found a solution for the same problem. I don't know what is exactly the solution but i solved it as it :
I restart from scratch. Backup my project folder in myproject.bak folder and
launch phonegap create myproject
cd myproject
cordova platform add android
I copied my project resources from myproject.bak into my new myproject
grunt phonegap:build:android
At this time i have already an error because of a file with accent in my projet. I found this error with the following command :
ant debug -f "/home/grattepoil/path/to/my/project/platforms/android/build.xml" -Dout.dir=ant-build -Dgen.absolute.dir=ant-gen -logfile log-ant.txt

Categories

Resources