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
Related
I've been at this for a whole day.
I created a new project using npx react-native init Project. But If I try to run it on android I get this:
FAILURE: Build failed with an exception.
* What went wrong:
Incompatible magic value 0 in class file java/util/logging/ErrorManager
I've went through the docs many times. When I run npx react-native doctor, I get this:
Android
✓ JDK
✖ Android Studio - Required for building and installing your app on Android
✖ Android SDK - Required for building and installing your app on Android
- Versions found: N/A
- Version supported: 29.0.3
✓ ANDROID_HOME
So there were a few things that were causing this issue.
✖ Android Studio - Required for building and installing your app on Android
It seems that npx react-native doctor looks for /opt/android-studio, after placing my android studio in /opt/, it was able to detect it.
✖ Android SDK - Required for building and installing your app on
Android
Versions found: N/A
Version supported: 29.0.3
From what I understood, react native uses sdkmanager script to look for sdk which comes with command line tools when you install android studio. In my case, when I ran the script it was giving me errors. The reason for that was that I hadn't created JAVA_HOME environment variable. So, after creating the environment variable and adding it to PATH, the sdkmanager script ran successfully and so did the react native project.
TL;DR
You need to have your android studio folder in opt and it must be named android-studio.
Install android sdk command line tools(latest) and add it to your PATH like this export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
Also create JAVA_HOME and add it to PATH.
It's look you don't have installed Android Studio in your system.
Try to install from official site https://developer.android.com/studio#downloads
Or use snap https://snapcraft.io/install/android-studio/manjaro
sudo snap install android-studio --classic
When I want to try ionic weather app (https://github.com/driftyco/ionic-weather/) I've got problems when I wanted to build android to my phone-gap application using cordova. I receive this message in terminal when I execute the command cordova build android
Error: An error occurred while listing Android targets
I work on ubuntu 13.10
I was able to successfully build the project with the following steps:
npm install -g cordova ionic
git clone https://github.com/driftyco/ionic-weather/
cd ionic-weather
cordova platform add android
cordova build android
You may be missing the required android sdk tools, or they may not have been added to your system path.
Refer to this question
cordova ubuntu: An error occurred while listing Android targets
And follow this guide to ensure your environment was setup correctly.
I'm new to cordova mobile app development. I have install Node and then install cordova. i have done those steps to create a cordova android app.
cordova create hello com.example.hellow HelloWorld This work fine
cd hello Navigation to directory_
cordova platform add android This is not working
This is the error showing my terminal
Jeys-MacBook-Pro:hello mactec$ cordova platform add android
Creating android project...
/Users/mactec/.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/mactec/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:85:29
at _rejected (/Users/mactec/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
at /Users/mactec/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
at Promise.when (/Users/mactec/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/Users/mactec/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
at /Users/mactec/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
at flush (/Users/mactec/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Error: /Users/mactec/.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:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
Jeys-MacBook-Pro:hello mactec$
Please help me to short-out this issue
Thanks in advance.
The problem is PATH wrongly defined on .bash_profile.
What i have done for this.
Change the path on bash profile open ~/.bash_profile. Then the bash profile open in a text editor.
Add the correct path to android SDK. If we have android studio then the path is /Application/Android Studio.app/sdk/ so we need to add this path to .bash_profile. export PATH=${PATH}:/Applications/Android\ Studio.app/sdk/tools
Then close all terminal and open again and code... :)
You can check that is working or not via typing android on terminal.
The error show in quite clear.You have to have the android sdk installed and proper path set in the system variable for the SDK, for cordova to work.See the prerequisites in cordova documentation http://cordova.apache.org/docs/en/3.0.0/guide_cli_index.md.html.For cordova 3.4 project android SDK must have target 19 installed.
Download SDK here http://developer.android.com/sdk/index.html
Here is the platform guide for more information http://cordova.apache.org/docs/en/3.0.0/guide_platforms_android_index.md.html#Android%20Platform%20Guide
If you already have the SDK installed,check to see if the path is refered properly for cordova to find
There's also another potential cause for this error: an errant file in your project/www directory. I had inadvertently included a blank file called project/www/:q ("colon q") in www/ (note I use Vim)! Anyway, doing this yields the exact error as noted by JeyTheva. So, delete that file and do the following:
cordova platform remove android
rm -r ~/.cordova/lib/android
cordova platform add android
Now rebuild and run on your device. This should work if you did something similar to what I did.
I have a phonegap created for iOS, and I want to build it for Android, but the following commands would not convert it to an Android project:
phonegap platform update android
phonegap install android
phonegap build android
Here is one of the errors that I receive:
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ phonegap platform update android
[phonegap] updating Android platform...
[error] Platform "android" is not installed.
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ phonegap install android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] trying to install app onto device
[phonegap] no device was found
[phonegap] trying to install app onto emulator
[error] The provided path "/home/lucas/Dropbox/projects/ecostartup/ecometrix-app/platforms/android" is not an Android project.
Here is another error:
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ phonegap build 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.
/home/lucas/.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 /home/lucas/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:87:29
at _rejected (/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:808:24)
at /home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:752:41)
at /home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:574:44
at flush (/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$
And here is some project info:
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ ls
platforms plugins README.md www
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ ls platforms/
ios
How can I convert this to Android?
actually looking at your logs, it seems that the app has been built. The only visible error is that no phone was detected and the emulator could not be started.
About the commands you use :
phonegap platform update android this one is for when you already added android platform to your project and installed a newer version of phonegap so you don't need it for the moment
phonegap install android here you're trying to install your app to a device connected to your computer with proper drivers installed and debuging allowed
phonegap build android here you go, this is the good command to build the android project and generate a debug apk.
Once you run build, you should find the debug apk in platforms/android/bin
If you use some plugins, also check that they are compatible with android.
I double checked to make sure that Android was on my path:
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app/platforms$ echo $PATH
(rest of path)...:/opt/android-sdk-linux/sdk/tools:/opt/android-sdk-linux/sdk/platform-tools
But I needed to install Cordova:
sudo npm install -g cordova
and I ran phonegap build android, which gave me another error to install Ant:
sudo apt-get install ant
This was all after installing nodejs, npm, and phonegap.
I found this post very helpful:
PhoneGap/Cordova Android Development
(it just took me a while to find it)
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