This week I setup my phone gap environment for development. It wasn’t as simple as I thought it was. Phone gap has a few dependencies needed for it to run and installation is done all via the command line.
Dependencies
Nodejs
To install phonegap you must use Nodejs’s packages manager – npm
My first step was to install Nodejs.
Upon installing , nodejs creates a local variable to gain access to its features over the command line – one of these features is npm (node package manager) using npm you can install software through the command line.
Java
Java is needed for phonegap to be able to compile the project into a android app.
For windows apps you will need the .net framework.
SDK
SDK(software developer kit) is also needed to compile the phonegap project. Android studio comes bundled with the SDK so I downloaded android studio.
Installing phone gap
With nodejs’s npm all that I need to do is run the command
npm install -g phonegap
Creating a project
Now that phonegap is installed , its time to create a project.
when phonegap is install the system variable is installed with it – phonegap
to create an project I need to run the command: (in the desired directory)
phonegap create appname
cd to the directory
and add a phone platform
phonegap add platform android
npm will take care of the rest
To emulate my app it need to build then run. During this process I got an error
After some research into this problem I found a solution. There was something wrong is my .gradel folder. By deleting the .gradle folder phonegap had to fetch a new .gradel folder (via npm) upon build. Doing this fixed the problem.
After building my app I can now run it using the android emulator
phonegap emulate android
Heres where I meet another problem , the emulator is not working. After some research I discovered that I needed a CPU wich supports Intel HAXM . Luckily I was able to change the emulators CPU to ARM
This fixed the problem but it made the emulator run alot slower.
Heres some images of the emulator running
Phonegap Build
After some more reading I discoved that phonegap offers an cloud service to build your app
All you need to do is zip the app and upload it. Once uploaded there is a QR code you can scan to install the app on your phone. This is a much easier solution and it allows me to test it on my mobile device!