Issues with cordova and android studio - android

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

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.

cordova platform add android launches android in different window

I am trying to create my first android project using cordova on my Windows 7 machine. I have installed latest Android SDK and cordova. I have set path for ANDROID_PATH, ANDROID_PLATFORM_TOOLS, ANDROID_TOOLS and ANT_HOME.
Using directions from http://cordova.apache.org/docs/en/3.6.0//guide_cli_index.md.html#The%20Command-Line%20Interface I have created the "hello" project but as I try to add android platform using:
cordova platform add android
from my command prompt android emulator opens up showing android home screen, so I can navigate through the OS but soon as close it I get the output:
C:\devCenter\private\hello>cordova platform add android
Creating android project...
C:\Users\think ahead\.cordova\lib\npm_cache\cordova-android\3.6.3\package\bin\node_modules\q\q.js:126
throw e;
^
Error: Please install Android target "android-19".
Hint: Run "android" from your command-line to open the SDK manager.
at C:\Users\think ahead\.cordova\lib\npm_cache\cordova-android\3.6.3\package\bin\lib\check_reqs.js:173:19
at _fulfilled (C:\Users\think ahead\.cordova\lib\npm_cache\cordova-android\3.6.3\package\bin\node_modules\q\q.js:798:54)
at self.promiseDispatch.done (C:\Users\think ahead\.cordova\lib\npm_cache\cordova-android\3.6.3\package\bin\node_modules\q\q.js:827:30)
at Promise.promise.promiseDispatch (C:\Users\think ahead\.cordova\lib\npm_cache\cordova-android\3.6.3\package\bin\node_modules\q\q.js:7
at C:\Users\think ahead\.cordova\lib\npm_cache\cordova-android\3.6.3\package\bin\node_modules\q\q.js:574:44
at flush (C:\Users\think ahead\.cordova\lib\npm_cache\cordova-android\3.6.3\package\bin\node_modules\q\q.js:108:17)
at process._tickCallback (node.js:419:13)
Error: cmd: Command failed with exit code 8
at ChildProcess.whenDone (C:\Users\think ahead\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
C:\devCenter\private\hello>
There is no android directory created inside platforms in "hello" project. Can someone please help me in pointing what I am missing/doing wrong.
EDIT:
I have updated SDK with API-19 but I still getting the same problem. Is there anything else I have to do?
Run the SDK Manager.exe from your /android-sdk/ folder and make sure you install the
SDK Platform for Android 4.4.2 (API 19). Once that is done you just rerun the cordova command.
From folder ADT-x86 (your SDK) run SDK manager.exe, then you search Android 4.4.2 (API 19). check it! and you press install, before that you need to accept license agreement first, it was help me to solve that matter, hope this help :)

Cordova wants android-19, I have android-20

There are many questions here regarding problems running "cordova add platform android" command. I've tried each purposed solution and none have helped me.
Error message:
~/sandbox/hello$ cordova platform add android
Creating android project...
/home/acras/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:126
throw e;
^
Error: Please install Android target 19 (the Android newest SDK). Make sure you have the latest Android tools installed as well. Run "android" from your command-line to install/update any missing SDKs or tools.
at /home/acras/.cordova/lib/android/cordova/3.5.0/bin/lib/check_reqs.js:80:29
at _fulfilled (/home/acras/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/home/acras/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/home/acras/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:760:13)
at /home/acras/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:574:44
at flush (/home/acras/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Error: /home/acras/.cordova/lib/android/cordova/3.5.0/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/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)
I did what the error message tells me (run android and installed all packages) but the error persists.
PATH: Android SDK home, tools and platform-tools are in the path
In the platforms folder inside android sdk I have only android-20 and android-L folders.
I guess if I add android-19 OR make cordova want android-20 will solve my problem. What should I do to achieve both options?
Thank you
The current Cordova (4.1.2) only wants to build against API v19
> cordova build android
Running command: /Users/Duncan/Documents/Work/rescyoume/cordova/platforms/android/cordova/build
[Error: Please install Android target "android-19".
Hint: Run "android" from your command-line to open the SDK manager.]
To install v19, run android as it suggests and then, in the GUI that opens, select Android 4.4.2 (API 19)/SDK Platform in the tree and click the Install packages... button.
You need to download Android 4.4.2(API 19) because target API is set to 19 in android manifest file. Either change it to the API that you have already downloaded or download API 19
In terminal type the command
$ android
this will open the Android SDK manager.
Check the API 19 SDK Platform checkbox and download it.
Now when you type command
$ cordova platform add android
should work fine.
If are you using Linux,
Install ant:
sudo apt-get install ant
Export the correct sdk path:
export PATH=${PATH}:/<sdk path>/sdk/platform-tools:/<sdk path>/sdk/tools

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

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