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
Related
I just executed the command "ionic build android" on my ionic 2 project and it was done successfully it says. But there is no APK file generated. What am I supposed to do? Thanks in advance. I'm using node v6.11.2, Ionic CLI 3.7.0, cordova 7.0.1.
First create an account at ionic Io
than hit this ionic Io init in project directory
after login hit this ionic package build android
after successful your apk file store in your cloud and download it and install
The Path as mentioned before is the correct path to find your generated apk file.
yourProject/platforms/android/build/outputs/apk/android-release-unsigned.apk
Please check these steps if there something missing.
I. Development environment dependencies
1)You need at Least to download a java JDK 8
2)Download an Android SDK manager
3)you must Add them to the environment variables
(Windows)
i)Open environment variables
ii)ANDROID_HOME:create a new user variable with name ANDROID_HOME and add the path of the SDK manager
ex.C:\xxx\Android\sdk
iii)edit the user variable PATH value and add to it platform tools path ex. C:\xxx\Android\sdk\platform-tools
iV)JAVA_HOME:Don't forget also to edit in the user variable PATH, your old JAVA_HOME env path with the new JDK Path . ex.C:\Program Files\Java\jdk1.8.0_144
4)Globally install ionic and cordova
npm install -g ionic cordova
II. Ionic CLI for build android
5)ionic cordova platform add android
6)ionic cordova build android
N.B: there sometimes logging in issue through CLI when using this command, the next steps doesn't really make sense but it worked for me.
ionic config set backend pro -g
Retry the build process again ,if Still there a problem change to legacy and Then again back to pro
ionic config set backend legacy -g
ionic config set backend pro -g
It should work now, retry the build process again.
If still there a problem then make an app through the website of ionic
use this command with the --pro-id of your app and retry again.
ionic start --pro-id <ID>
Follow this steps
Run ionic cordova build --release android
Open android studio go to Build -> Generate Signed APK, press next
If you don't have Key store please create new one
Finish
you can find the APK under Platforms/android
I want to upgrade cordova-1.6.0 into cordova-3.5.1 for android. But I did not found cordova-3.5.1.jar and cordova-3.5.1.js file. From where I will downlaod it. Also most the SO posts suggest some command line arguments but however I am using windows, so that doesnot work.
I am new to Cordova Kindly help me and suggest the right direction.
Well to install latest cordova you should using there CLI, it is easy and much maintainable.
Also there is no issue in installing it on windows ( if you follow proper steps ).
Following are some pre-request which come to my mind.
Android sdk : Make sure sdk\platform-tools and sdk\tools are in Global Environment Variables.
Ant : Make sure ant is present in your system and is included Global Environment Variables.
NodeJs/NPM : Make sure node/npm is installed in your system and is included Global Environment Variables.
GIT : Make sure GIT is installed in your system and is included Global Environment Variables.
If all above are fine then you can use following command to install Cordova :
npm install -g cordova
I just went to Phonegap and saw that I needed to install node.js to get started.
I did this, then followed the command line to install phonegap.
However, where is it? I don't see anything in my program files folder, I don't see Eclipse, and there's no documentation on what to do next on Phonegap's website. I don't understand why this instruction is so vague? What am I missing? And where did all those files I downloaded/installed go go?
Thanks
Phonegap 3.3 installation there is no proper info in phonegap site.
The reason of installing nodejs is, phonegap cordova are created as node modules.
Required Software’s:
Follow the steps. 1 Node Js 2 ANT 3 Android_sdk 4 JDK
open command prompt:
Follow the steps
C:\user\youruser>npm install -g phonegap
C:\user\youruser>npm install -g cordova
Set Environment variables:
Mycomputer -> Right Click -> properties -> Advance System settings -> Environment
variables
set path for 1. Java JDK 2. Android SDK 3. ANT
C:\user\youruser>cordova platform add android
C:\user\youruser>phonegap create First-app
C:\user\youruser>cd First-app
C:\user\youruser>phonegap run android
Phonegap will be installed and apk will be created in bin folder.
You will be getting
[phonegap] detecting Android SDK environment..
[phonegap] using the local environment
[phonegap] compiling Android...
[phonegap] successfully compiled Android app
[phonegap] trying to install app onto device
[phonegap] successfully installed onto device
You can able to see phonegap modules in C:\Users\yourusername\AppData\Roaming\npm.
Hope this will be very helpful. Let me know if you face any issues.
Phonegap installation steps present on the official site are somewhat vaguely presented and hasn't been properly updated.
With respect to your question, I think this post https://stackoverflow.com/a/18751002/4277415 might help you out.
Cheers.
Install phonegap without any error : http://www.markupjavascript.com/2014/07/installing-phonegap-in-windows.html
I have an issue with setting up an Android Project on Mac OS.
with the command:
$cordova platform add /path/to/androidSDK/android
I've got the error message:
[Error: Platform "/path/to/androidSDK/android" not recognized as core cordova platform.]
Does anyone have the same Issue ? How can I fix that ?
latest Android SDK version (downloaded today).
Phonegap version: 3.1.0-0.15.0
OSX 10.9 Mavericks
To install the cordova command-line tool, follow these steps:
First of all go through the Cordova Document
For Cordova command-line tools to work, you need to include the SDK's tools and platform-tools directories in your PATH environment. On Mac, you can use a text editor to create or modify the ~/.bash_profile file, adding a line such as the following, depending on where the SDK installs:
export PATH=${PATH}:/Development/adt-bundle/sdk/platform-tools:/Development/adt-bundle/sdk/tools
Next Steps:
Download and install Node.js from Here. Following installation, you should be able to invoke node or npm on your command line.
Install the cordova utility. In Unix(Mac), prefixing the additional sudo command may be necessary to install development utilities in otherwise restricted directories:
For Mac $ sudo npm install -g cordova
once successful installation of cordova is done ,now you can create your application
across all the platforms.
Create the Cordova Application
Go to the directory where you maintain your source code, and run a command such as the following:
$cordova create hello com.example.hello CordovaDemo
hello is the directory where you want to create your application
com.example.hello is the package name
CordovaDemo is the name of the Application
Once Successful creation of your project, some file will be created inside the directory i.e hello
Add Platforms
All subsequent commands need to be run within the project's directory, or any subdirectories within its scope:
$ cd hello
Now you need to specify a set of target platforms, Supported OS for Mac
$ cordova platform add android
plz tell me if you are still having problem.
Hope this will help you.
this is documentation Phonegab docs
and my .bash_profile:
export PATH=${PATH}:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/platform-tools:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/tools
visit the solution here
I hope this helps you
I am new to phonegap. I already have ADT in my PC.
1)I installed NodeJs.
2)I wrote on cmd
npm install -g phonegap
phonegap create my-app
cd my-app
phonegap run android
[phonegap]detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[error] No platforms added to this project. Please use 'cordova platform add <platform>'.
Here I already set the correct PATH. But the same problem occurring. If anyone knows plz let me know.
Thnx
Still not working .. Can anybody knows this .. Plz .. Thanks in advance..
I added these path for android: -
D:\adt-bundle-windows-x86\adt-bundle-windows-x86\sdk\platform-tools\
D:\adt-bundle-windows-x86\adt-bundle-windows-x86\sdk\tools\
and Java path is already set here.. So What's the problem here.. anyone can give the solution plz
EDIT: THIS ANSWER USES CORDOVA, NOT PHONEGAP
You must tell cordova which platforms you are going to use (e.g. android)
therefore, before executing command $cordova run android you must (once) execute cordova platform add android
For more details, see my answer here: Phonegap How to make android build
Regards, miweiss
At last I got the solution
Initially I wrote the command cordova platform add android, Then it was showing the error :
No platforms added to this project. Please use 'cordova platform add <platform>'.
I did some changes:
I change it to cordova -d platform add android
I reset all path, reset means again set my JAVA_HOME path and ANT_HOME path and then I gave the command cordova -d platform add android
then it was again showing error like There is no script engine for file extension .js. Then just use the command in commmand prompt assoc .js=JSFILE and put the command on prompt cordova -d platform add android and its done, now it contains android folder within platforms.
Thank You All for help
For Mac
just add the cordova path :
export PATH=$PATH:/usr/local/lib/node_modules/phonegap/node_modules/cordova/bin:/usr/local/bin
now add platform like :
cordova platform add android
the platform will be added.