Whenever I try to build a project using phonegap run, I get the below error:
C:\Users\MS AwaN\my-app>phonegap run android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[error] An error occured during creation of android sub-project.
C:\Users\MS AwaN\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at C:\Users\MS AwaN\.cordova\lib\android\cordova\3.3.0\bin\lib\check_reqs.js:87:29
at _rejected (C:\Users\MS AwaN\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:808:24)
at C:\Users\MS AwaN\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:834:30
at Promise.when (C:\Users\MS AwaN\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:1079:31)
at Promise.promise.promiseDispatch (C:\Users\MS AwaN\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:752:41)
at C:\Users\MS AwaN\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:574:44
at flush (C:\Users\MS AwaN\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:108:17)
at process._tickCallback (node.js:415:13)
Can anyone please suggest what I am doing wrong?
I had the same problem and this fixed it. Alternately look here (which is the same but has a link to the documentation which I also missed).
It seems that phonegap 3.3 requires android sdk 19.
If you have a older one, try the following steps :
delete the platforms/android folder (as the log say "Adding the android platform", I assume you didn't perform any customisations in that folder)
use android sdk manager to install the latest sdk
retry with phonegap build android and if it fails, run phonegap -V build android to get more details on the error
Related
I'm not cordova/android expert. I was provided with build steps to build some cordova project. However they stopped working after quite some time. I'm using old cordova 6.5.0 to build a cordova project for android. I don't believe i've changed any setup or libraries. I deleted my android studio and android sdk and installed them again. And Now i'm getting lots of weird errors like:
When i do cordova build android
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
Error: Error
at /platforms/android/cordova/lib/check_reqs.js:313:19
at _fulfilled (XXX/platforms/android/cordova/node_modules/q/q.js:854:54)
at self.promiseDispatch.done (XXX/platforms/android/cordova/node_modules/q/q.js:883:30)
at Promise.promise.promiseDispatch (XXX/platforms/android/cordova/node_modules/q/q.js:816:13)
at XXX/platforms/android/cordova/node_modules/q/q.js:877:14
at runSingle (XXX/platforms/android/cordova/node_modules/q/q.js:137:13)
at flush (XXX/platforms/android/cordova/node_modules/q/q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:95:7)
at process._tickCallback (internal/process/next_tick.js:161:9)
I do have ANDROID_HOME:
/root/Android/Sdk
and $PATH:
echo $PATH
/home/XXX/.sdkman/candidates/gradle/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/usr/lib/jvm/java-8-oracle/bin:/home/XXX/dev/tools/idea-IU-145.258.11/bin:/root/Android/Sdk/tools:/root/Android/Sdk/platform-tools:/home/XXX/.sdkman/candidates/gradle/4.4.1/bin
I tried building it with android studio, supplying various version of gradle, but i always get stuck with some weird errors.
How can i understand what have happened? What versions of which libs i suould use?
Thanks
I am trying to create a simple project in phonegap with association of wikitude.
This is the tutorial which I followed - wikitude + phonegap tutorial
And I am using ubuntu 12.04 these are the only steps which I followed,
$ npm install -g phonegap - Adding phonegap
npm install plugman - Adding plugman
sudo npm install -g cordova - installing codova
Then following steps to create app,
$ phonegap create MyAugmented - create app
$ phonegap build android - build in android
Aditionally I have installed android sdk using apt-get.
But when I build this app using above build command it gives an error,
Error in Text :
Error: An error occurred while listing Android targets
at /home/sachith/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:87:29
at _rejected (/home/sachith/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
at /home/sachith/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/sachith/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/sachith/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
at /home/sachith/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
at flush (/home/sachith/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
{ [Error: /home/sachith/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8] code: 8 }
[error] /home/sachith/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8
Answers would be really appreciated,
Thanks in Advanced.
Most probable reason is you don't have latest android SDK. So update your android SDK and it should work fine.
You can reference this to see way of finding error.
Cordova has a script to check if all dependencies are present. Is is
called when you run cordova platform add android but unfortunatly it's
output is not displayed when it fails.
You can try to run it manually, it should be
$home/.cordova/lib/android/cordova/3.3.0/bin/check_reqs
The normal output when everything's fine is "Looks like your
environment fully supports cordova-android development!", oterwise it
should display a clear message about what's missing.
Maybe your issue is that you havent't installed SDK platform for API
19 in android sdk manager (cordova 3.3 uses target sdk 19).
UPDATE:
Android SDKs are updated using SDK Manager. You can see how to use SDK from here.
http://developer.android.com/tools/help/sdk-manager.html
I'm trying add the android platform to my cordova project, though I get the error:
$ cordova platform add android -d
cordova library for "android" already exists. No need to download. Continuing.
Checking if platform "android" passes minimum requirements...
Checking Android requirements...
cordova library for "android" already exists. No need to download. Continuing.
Error: An error occurred while listing Android targets
at /home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/lib/check_reqs.js:83:29
at _rejected (/home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:808:24)
at /home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:752:41)
at /home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:574:44
at flush (/home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Without the -d it will be:
Checking Android requirements...
[Error: An error occurred while listing Android targets]
I'm not sure what configuration I am missing. In my ~/.bashrc file I have:
### Java
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
export ANDROID_HOME=~/Code/adt-bundle-linux-x86-20131030/sdk/tools
export ANDROID_PLATFORM_TOOLS=~/Code/adt-bundle-linux-x86-20131030/sdk/platform-tools
export PATH=$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH
and I have ant installed:
$ ant -version
Apache Ant(TM) version 1.8.2 compiled on December 3 2011
What's missing? Why do i get the error An error occurred while listing Android targets when trying to add the android platform to the cordova project?
Cordova has a script to check if all dependencies are present. Is is called when you run cordova platform add android but unfortunatly it's output is not displayed when it fails.
You can try to run it manually, it should be $home/.cordova/lib/android/cordova/3.5.0/bin/check_reqs
The normal output when everything's fine is "Looks like your environment fully supports cordova-android development!", oterwise it should display a clear message about what's missing.
Maybe your issue is that you havent't installed SDK platform for API 19 in android sdk manager (cordova 3.3 or 3.5 uses target sdk 19).
Update: Cordova 3.3 or 3.5 works on SDK 19 only (Android 4.4.2). The error logs does not mention clearly what platform version it is looking for. Typically error messages are:
Unable to add platform android. Please see console for more info.
or
[Error: An error occurred while listing Android targets]
This can also happen when android (sdk/tools) is not in path. I would have loved if the check-script have printed correct error message. BTW, created a PR for them.
in .bashrc try adding
export ANT_HOME="/usr/bin/ant"
export PATH="$PATH:$ANT_HOME/bin"
export HOME="/home/username"
export ANDROID_HOME="$HOME/android-bundle/sdk/tools"
export ANDROID_PLATFORM_TOOLS="$HOME/android-bundle/sdk/platform-tools"
export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH"
or try explicitly define the paths globally.
from the terminal I type:
export PATH=${PATH}:~/dev/adt-bundle-linux-x86_64-20140321/sdk/tools
export PATH=${PATH}:~/dev/adt-bundle-linux-x86_64-20140321/sdk/platform-tools
(rememebr to replace with your own sdk path)
If this doesn't work, try updating the sdk
Please Refer the Question
An error occurred while listing Android targets
and the Link
developer.android.com/tools/devices/managing-avds-cmdline.html
Most probably the path variable pointing to this android was wrong. I had used %ANDROID_HOME% as variable and scaled the same to path variables %ANDROID_HOME%\SDK\TOOLS. This method doesn't work. Experimentally resolved by directly pointing to the Tools and Platform Tools.
Just based on what I did and it worked for me. Hope You get the Issue resolved
I had faced the Issue even after the Cordova check_reqs was working correctly without providing any error.But on adding a new platform this error was still being raised. The above method personaly resolved my issue.
I solved the problem giving full permission for my app folder
$ sudo chmod -R 777 myApp
After that, try again
$ cd myApp
$ ionic platform android
I'm trying to compile my phonegap project using the cordova cli on my Win8 machine. I've updated all my Android SDKs, updated cordova and phonegap but I cannot build my project. I get an error that the .cordova/hooks/any_hook is empty.
I looked in that directory and can't see any files in there. How do those files get there and is the latest version of cordova bad? Until now I've been compiling on my Mac because I couldn't get the PC setup correctly so today I decided to take a crack at it and have failed.
I even created a new hello world project using the CLI but still no luck in building the thing because of the supposed missing hook files. Anyone have any insight to this.?
Also, I've tried using the command prompt in both ADMIN and regular mode. Still no luck.
EDIT:
I'm using phonegap 3.3.0-4.18.0
Path to hooks:
Z:\projecttitleroot\projecttitle.cordova\hooks
OUTPUT OF PHONEGAP BUILD WITH DEBUG:
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] compiling Android...
[error] ENOENT, no such file or directory 'Z:\myprojectroot\myproject\.cordova\hooks\before_build'
I want to point out that I'm using phonegap command to compile and run, NOT cordova as per the documentation for the latest version.
If I run:
cordova -d build android
I get this:
Z:\myprojectroot\myproject>cordova -d build android
C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:126
throw e;
^
Error: ENOENT, no such file or directory 'Z:\myprojectroot\myproject\.cordova\hooks\before_build' at Object.fs.readdirSync (fs.js:654:18)
at C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\src\hooker.js:64:34
at _fulfilled (C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:798:54)
at self.promiseDispatch.done (C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:827:30)
at Promise.promise.promiseDispatch (C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:760:13)
at C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:821:14
at flush (C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\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)
Z:\myprojectroot\myproject>
Make sure you put your hooks into subdirectories inside the hooks directory.
Path to hooks: Z:\projecttitleroot\projecttitle.cordova\hooks\before_build\
I 'm trying to create a new project with phonegap3 :-
I set up the dev environment that include
node.js
Ant
Android SDK
and they all updated to the last versions
after creating the project , I get the directory for project:
EX :
phonegap create HelloWorld com.example.hello HelloWorld
but the main problem that I can't add the android platform to it
with the 3 comands as follow :-
trying to "phonegap add platform android"/"phonegap build android"/"phonegap run android"
I also installed throw the node the "cordova" and the same problem exists when I replace the phonegap with cordova !
Users\koko\test\www>phonegap build android
[ponegap] detecting Android SDK environment...
[ponegap] using the local environment
[onegap] adding the Android platform...
[error] An error occured during creation of android sub-project.
Users\koko\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at C:\Users\koko\.cordova\lib\android\cordova\3.3.0\bin\lib\check_reqs.js:87:29
at _rejected (C:\Users\koko\.cordova\lib\android\cordova
.........
at process._tickCallback (node.js:415:13)
I also uninstall the node and re-download it and the problem still exists !
I viewed many questions with people around this issue but I don't know where exactly the error !
I wish to see the project running inside the emulator !
It seems, that cordova failed to execute following command in shell:
>android list target
Why don't you try to execute it manually? It may produce more information about this problem.
Didn't you forget to add following folders to your PATH?
android-sdk/tools
android-sdk/platform-tools
EDIT:
The latest android SDK has different folder structure. note the "sdk" folder.
android-sdk/sdk/tools
android-sdk/sdk/platform-tools
Make sure, you have set the following system variables:
ANT_HOME = path to ant files
JAVA_HOME = path to java JDK (NOT JRE!!)
ANDROID_HOME = path to android sdk
After that, you have to add
%ANT_HOME%\bin
%JAVA_HOME%\bin
%ANDROID_HOME%\bin
to your PATH variable.
If it still doesnt work, make sure you have the Google USB Driver installed (this took me hours to find and fix -.-)