venerdì 2 gennaio 2015

Build and run Android based on Cordova with Mac OS

If you want to build android on Mac OSX you first have to install the Android SDK then add it to the PATH variable.
Upgrade the SDK version to the latest possibile but also download the Android 4.4.2 (19 version with latest revision).

SDK: http://dl.google.com/android/android-sdk_r24.0.2-macosx.zip


1- With a command line on your cordova project run:
$ cordova platform add android
2- Create an android emulator
$ cd ~/.android/avd
$ android create avd -n my_android -t 2 --abi default/x86
2- Build the project
$ cd your_project
$ cordova build android
4- Open the GUI application Android SDK Manager:
$ android
5- Install the Intel HAXM hardware acceleration selecting and installing the package:

Intel x86 Emulator Acceleration (HAXM installer)

Then after dowloading this package open the dmg file on SDK/extras/Intel and install it

6- Start the emulator (this open the app)
$ cordova emulate android

If HAX is not installed or you want to run on a real device, connect to the Mac though USB cable, then locate the apk built before and install it on the device:

$ adb install your_project/platform/android/ant-build/CordovaApp-debug.apk
Then open the app on the device.

Nessun commento:

Posta un commento