Using android studio to compile phonegap apps in cmd setup – Windows
I am just writing down the shit here so that when I move to a new pc I can just copy and paste the detts.
Things we’ll need:
- Android Studio
- Java JDK v1.7+ – Installation notes (Make sure its not the JDR, made this mistake)
- Apache Ant (for compiling)
- Node.js
- Phonegap
- Some knowledge of copy/paste and how to read from images. If you’re blind what the hell are you doing developing for apps anyway)
Step 1 – Installing stuff
Android Studio
Download and Install Android Studio.
The location is up to you, but I find it easiest to put it at the root of my C drive. I conveniently created a folder amply called “phonedev” folder.
C:\phonedev\sdk\
Once installed you’ll just have a folder full of stuff.
Java JDK
I’ve already got this installed so can’t take print screens for myself.
But good, its installed.
Node.js
Bog standard install please.
Phonegap
With node.js installed we can now install phonegap. From cmd (start->run->cm
d) sudo npm install -g phonegap
Apache Ant
Download the latest version, this can be any format you want, I go with zip as it has the most support: http://tweedo.com/mirror/apache//ant/binaries/apache-ant-1.9.3-bin.zip
Extract that to the phonedev folder you created eariler, it should like this once extracted: C:\phonedev\apache-ant-1.9.3
and for now you’re done.
System Variables
Now is the fun part:
bring up the advanced system variables. Easiest way is hitting Windows Key+Pause
on your keyboard. This will just bring up the Control Panel -> System
From there you want to click the Advanced system settings:
Then click Envrionment Variables
This little guy is where we tell the computer where the hell we installed anything.
Adding new variables
You need to add two new variables, to do this click New
under the System variables
section. Thats the second new tab in this little window.
Now add these two:
- ‘ANDROID_HOME’:’C:\phonedev\sdk’
- ‘ANT_HOME’:’C:\APACHE-ANT-1.9.3′
Now scroll down the list and fun straight up Path
Now add the following to the end of the list:
- C:\PROGRAM FILES\JAVA\JDK1.7.0_45\BIN;
- C:\PHONEDEV\APACHE-ANT-1.9.3\BIN;
- %ANT_HOME%\BIN;
- %ANDROID_HOME%\TOOLS;
- %ANDROID_HOME%\PLATFORM-TOOLS;
or if its more simple just paste this in at the end.
C:\PROGRAM FILES\JAVA\JDK1.7.0_45\BIN;C:\PHONEDEV\APACHE-ANT-1.9.3\BIN;%ANT_HOME%\BIN;%ANDROID_HOME%\TOOLS;%ANDROID_HOME%\PLATFORM-TOOLS;
Worth noting that before pasting this in, make sure the last variable in the last already has a ;
Otherwise it’ll just break things.
Before Pasting… Notice the trailing ;
After Pasting
Verifying things worked
- Check Ant:
ant -version
- Check Node:
node -v
- Check Java:
java -version
- Check Phonegap:
phonegap -version
If all went well all of the above will look like this:
At last the best bit, check everything is working.
Phonegap create helloworld
Now move into that folder:
cd ./helloworld
phonegap build android
Now cream everywhere!!
Although there is actually a lot more you should know, but as i’m just doing it for reference when my PC next crashes, maybe if somebody ask’s I’ll do it.