I am new to ionic. I am able to install ionic and also create a new project based on this link http://ionicframework.com/docs/guide/installation.html.But when I try to add a platform it says failed with exit code ENOENT.
I tried to yield debug information by "ionic -d platform add android" as suggested in https://stackoverflow.com/a/32360435/5820057.
I got this msg.
What does it mean? "Failed to find bower component 'android'". Is there any issues with the CLI version?
Android on OS X note gives you an error, searching it;
typing "?
Make sure JAVA_HOME is set, as well as paths to your JDK and JRE for java in browser tab" will result in cordova based errors.
means ionic is wrapper around cordova, so most probably cordova will give you the exact error.
Also make sure all required variable are available in PATH.
Related
I have a jenkins job that is supposed to create a cordova app but it's failing some reason that I can't quite identify. The jenkins job simply does this:
cordova platform add android
cordova prepare android
cordova build android --debug --verbose
The first command (cordova platform add android) is resulting in the following error:
ENOENT: no such file or directory, mkdir 'platforms/android/app/src/main'
Error: ENOENT: no such file or directory, mkdir 'platforms/android/app/src/main'
at Object.mkdirSync (fs.js:738:3)
at Object.module.exports.makeDirSync (/Users/me/Documents/Jenkins/sharedspace/apps/my-app/cordova/node_modules/fs-extra/lib/mkdirs/make-dir.js:23:13)
at /Users/me/Documents/Jenkins/sharedspace/apps/my-app/cordova/node_modules/cordova-android/lib/create.js:231:16
+ /Users/me/.nvm/versions/node/v16.13.2/bin/cordova prepare android
(node:23901) ExperimentalWarning: The fs.promises API is experimental
Discovered platform "android". Adding it to the project
EEXIST: file already exists, mkdir '/Users/me/Documents/Jenkins/sharedspace/apps/my-app/cordova/platforms'
+ /Users/me/.nvm/versions/node/v16.13.2/bin/cordova build android --debug --verbose
(node:23902) ExperimentalWarning: The fs.promises API is experimental
No platforms added to this project. Please use `cordova platform add <platform>`.
CordovaError: No platforms added to this project. Please use `cordova platform add <platform>`.
at Object.preProcessOptions (/Users/me/.nvm/versions/node/v16.13.2/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/util.js:275:15)
at /Users/me/.nvm/versions/node/v16.13.2/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/build.js:29:31
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
at startup (internal/bootstrap/node.js:236:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:560:3)
Build step 'Execute shell' marked build as failure
When I look inside the platforms directory on the jenkins box it is empty. It is able to create the platforms folder itself, just nothing else under. It doesn't seem to be a permission issue as far as I can tell. If I ssh into the box as the same user that jenkins in using I can run the cordova commands fine and everything works.
Furthermore, if I add the platform manually by sshing into the box and then let jenkins take over after the android folder already exists, the job works fine. So I guess for some reason it's not able to add the android project.
If it helps, this is what cordova requirements gives:
cordova requirements
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-30,android-29,android-28
Gradle: installed /usr/local/Cellar/gradle/7.3.3/bin/gradle
Okay, I finally figured this SOB out! After taking a few weeks off and coming back to this I noticed that there is a setting in the job config called "Shared Workspace" and I had it set to the value (). I don't know what that means, but it had the effect of putting the code for this project in the
/Users/me/Documents/Jenkins/sharedspace
folder, which apparently was causing problems with cordova. Once I set the Shared Workspace value to NONE, it moved the project to the
/Users/trident/Documents/Jenkins/workspace/my-app
folder which is more what I would expect. After that, lo and behold, everything works.
I m cloning a cordova app sourcecode from github. How do I install cordova and add android platform to it and build it in Android Studio?
After cloning the code, I am installing cordova, but cant add platform or anything related to cordova. Is there any tutorial on how to follow the correct steps to make it run in Android Studio? I am very new to Cordova. Thanks!
First of all: follow the GitHub repo's README and look for installation instructions.
To play around with a cordova app, you most definitely need the cordova CLI. If you haven't already, install NodeJS and npm from http://nodejs.org or using your package manager of choice. Then inside a terminal run
npm install -g cordova
(If you are using Linux you probably have to run that command with sudo)
Now you navigate into the cloned github repo and run
cordova platform add android
cordova build android
It will create a directory under ./platforms/android which you can open using Android Studio. Then you can run the app with an emulator or a connected device.
If at any point you receive error messages or you think something is missing, you can run (inside the GitHub cloned repo)
cordova requirements
It will show you if the cordova CLI is missing something. You will have to fix all the errors that come up. Consult the cordova documentation under https://cordova.apache.org/docs/en/latest/guide/cli/#installing-the-cordova-cli in order to do that.
Hope this helped.
Please note I am not a programmer . I am ex Banker and entrepreneur now .I got really frustrated while setting cordova with all those errors for building android apps in windows. Though, I now understand this is the simplest cake, if you know the know-how. I love coding, so I am sharing the whole length of steps . You can figure out what step you are missing.
Step 1. Requirements :
(a)node js ( npm )-- install it
(b) Install cordova by command -->
npm install -g cordova
(c) Install Phone gap by command --> npm
install -g phonegap
(d) Ant apache ( download bin not source ) by visiting
https://ant.apache.org/bindownload.cgi . Keep this in C:/ Program files
(e) JDK version 8 . you can down load previous version by visiting
oracle.com
NOTE : Keep ( ANT ) and JDK in Same Folder i.e extracted (d) and (e) in C:/Program files
Step: 2 Setting Environment Variables
you can visit : Control Panel\System and Security\System--> environment variables You can see two types of windows : User and System
User Environment Variables:
You have to set ANT_HOME and JAVA_HOME
Add new variable :
Variable name :ANT_ HOME
Variable value : C:\Program Files\apache-ant-1.10.3
Variable name :JAVA_ HOME
Variable value :C:\Program Files\Java\jdk1.8.0_172
System Environment Variables: edit path and at the end use ; and paste ant/bin address
PATH :
Variable name :path
Variable value :....C:\composer;C:\Program Files\Git\cmd;C:\Program Files\apache-ant-1.10.3\bin
NOTE : Check ant & java configuration by windows command prompt :
ant -version and java --version . If using git then git --version.
If you error free then proceed further.
Step 3. Create a cordova project
something like this command: cordova create hello com.example.hello HelloWorld
Step 4. create platform android or ios: ensure proper config.xml
**Step 5. now check cordova requirements: This work in app folder only **
Now build your app.
Other errors you get if you miss these:
check ="ANDROID_SUPPORT_VERSION" in config xml.
Add Required Plugin - cordova plugin add -- as you need in config.xml
Cordova requirements: This work in app folder only
Cant find the Ant Version: you have not used ANT_HOME, JAVA_HOME folder name.Ensure ANT_Home and JAVA_HOME only in User folder while the path in System Variable. Never use / " or ' in writing these variables.
"IF YOU DONT REQUIRE ANT AND GIT ---> Dont download it "
Hope this helps beginners and code layman like me.
Answered on: Android Studio project detected
I am trying to create a PhoneGap application using WebStorm 2016.3 IDE.
I am following this link link. I am able to create a project from the steps but while running the app I'm getting errors. While setting emulator I've found that Android SDK was not found.
I am unable to find how can I set that path here and the error I got is:
...and in log cat
"C:\Program Files (x86)\JetBrains\WebStorm 2016.3\bin\runnerw.exe" "C:\Users\Sa E\AppData\Roaming\npm\ionic.cmd" run --emulator android
✗ You cannot run iOS unless you are on Mac OSX.
I've tried some things by google but the data is for old IDE and I can't see such options with my current IDE.
I ran into the same issues on Windows. I added a system variable ANDROID_HOME with the address of the sdk folder. In my case it was
c:\Users\Andrew\AppData\Local\Android\sdk
After that, I restarted WebStorm, and it works fine.
PS make sure that you set up the project properly. Try creating a new project with type "PhoneGap/Cordova", then in the terminal type the following commands:
ionic start MyProjectName
ionic serve
If everything works at this point, then proceed:
ionic platform add android
ionic build android
ionic emulate android
You can use run instead of emulate if you have GenyMotion installed and running
I used #Andrew's answer, but did not manage to make it work. It appears i needed more Environment variables; so, after many searches, I found this link on Cordova documentation which helped me in making PHPstorm recognize the Android SDK. The question was about Webstorm, but the Cordova plugin requires the same environment variables.
Here's a quote from that site (if you do not know how to set environment variables, follow the above link to get help):
Cordova's CLI tools require some environment variables to be set in order to function correctly. The CLI will attempt to set these variables for you, but in certain cases you may need to set them manually. The following variables should be updated:
Set the JAVA_HOME environment variable to the location of your JDK installation
Set the ANDROID_HOME environment variable to the location of your Android SDK installation
It is also recommended that you add the Android SDK's tools, tools/bin, and platform-tools directories to your PATH
I faced the same problem with intellij idea ultimate on linux, while trying to run a cordova/phone gap project. Weirdly enough, the commands where running normally from the command prompt and the embedded terminal, however, trying to create a run configuration, I got the infamous errors.
I have the environment variables set correctly, but, I have them set in ~/.bashrc which intellijidea seems not t read.
I tried to add the variables manually in the same screenshot you included, with no success. The solution was to add ANDROID_HOME to the /etc/environment, rebooted, and everything worked as expected.
I'm using Ubuntu Gnome 14.04 64 Bit (for the moment) with kernel 3.19.0-33-generic.
I created a new app (a clean one, no plugin, no www folder with content) to try to build it.
After type in the bash "cordova build android"
I get this error:
Running command: /home/aby/Desktop/testApp/platforms/android/cordova/build
[Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.]
ERROR building one of the platforms: Error:/home/aby/Desktop/testApp/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/aby/Desktop/testApp/platforms/android/cordova/build: Command failed with exit code 2
Now if you printenv | grep android
You will get
ANDROID_HOME=/opt/android-sdk-linux
ANDROID_PLATFORM_TOOLS=/opt/android-sdk-linux/platform-tools
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools:/home/aby/bin:/home/aby/opt/jdk8/jdk1.8.0_45/bin:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools
ANDROID_SDK=/opt/android-sdk-linux
You can see that the variables exist, in fact before I run cordova build android I had to use cordova platform add android and its works with no problem.
So I found this Bug, and tried some solution like update android(project) or remove and install it again with no success.
I reinstall the Andoroid SDK, and updated the "/.bashrc", "/.profile" and "~/.pam_enviroment" with the environment values and also this not help.
So how can I fix this? How can I build my app with no error? What I missing?(If you consider that you need another information please tell me).
Thanks, in advance.
At the end I could fix my problem when I change the "Owner" / "Group" to the android sdk folder and Permission to "/tools/android".
Here a link to my previous question, and the solution (at least for me) to fix this error.
[Well, I think an almost similar question was asked before, but the responses did not answer my question (in fact no answer was accepted in that thread). In this case I will appreciate detailed responses written with easy terminologies. Confession: I am pretty new with both PhoneGap and Webstorm.]
Getting to the point- I have installed ANT, Android SDK, node.js and PhoneGap. Next I created a project on CLI using the command "cordova create". What I want now is importing this project into Webstorm IDE to work further on it.
To clarify, I have tried "cordova build android" command. But it responds with a 'The provided path "..." is not an Android project'.
Is there anything else that I may try? My target is to load this project on Webstorm.
If you don't use PhoneGap plugin, please, read the tutorial: http://confluence.jetbrains.com/display/IntelliJIDEA/PhoneGap%2C+Cordova+and+Ionic
Note1: In the latest WebStorm 9 EAP PhoneGap plugin is bundled so you don't need step 1.
Note2: WebStorm 'new project' dialog a little different from the IDEA dialog.
Note3: If you need add existing PhoneGap project to WebStorm you can just use 'Open ...' quick start on the Welcome Screen.
Other:
Command 'cordova build android' can be started only after command 'cordova platform add android'.
I added the following paths to my (windows) path system variable:
.../ant/bin
.../android/.../sdk/platform-tools
.../android/.../sdk/platforms
.../android/.../sdk/tools
.../android/.../sdk
After that, it all worked fine