Huge Discounts on Mobiles, Books, Cameras, Computers etc: @Flipkart

Tuesday, June 09, 2015

Configuring Apache Cordova/Ionic

I wanted to create an app which can possible run on multiple platforms and decided to try Apache Cordova (earlier known as PhoneGap). It wasn't an easy sail as I thought it would be, had to spend many days to get the build to work finally. Even tried the ionic framework, but wasn't any better as it uses Cordova underneath.

The main issue I faced was the following error while building:
Error: Please install Android target 22
Tried many suggestions found online, still no luck! I had Android API 22 installed as per the Android SDK manager.

Finally I was able to get things working by doing the following:

  • Install NodeJS (used Windows installer)
  • Unzip latest ANT (1.9.4) and set ANT_HOME env var
  • Unzip Oracle Open JDK (32-bit, as per Visual Studio 64-bit won't work) and set JAVA_HOME
  • Unzip android SDK and set ANDROID_HOME, ADT_HOME and ANDROID_SDK_ROOT
  • Add %ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools; to PATH
  • Add \;%JAVA_HOME%\bin;%ANT_HOME%\bin; to PATH
Also try recreating the project or remove/add platform if build was not working and created it before doing the above.

The next issue was trying to emulate the build output (apk).
WARNING : no emulator specified, defaulting to Default
Waiting for emulator...
emulator: ERROR: no search paths found in this AVD's configuration.
Weird, the AVD's config.ini file is malformed. Try re-creating it.

I went to the Android SDK Manager (type 'android' in the shell) and tried creating a new AVD manually using existing Device template for Nexus 6. Found that CPU/ABI is missing and I need to install that first!

and then later
ERROR : No emulator images (avds) found.
1. Download desired System Image by running: android.BAT sdk
2. Create an AVD by running: android.BAT avd
HINT: For a faster emulator, use an Intel System Image and install the HAXM device driver

I first tried the "Intel x86 Atom_64 System Image, but ran into errors!
WARNING : no emulator specified, defaulting to AVD_for_Nexus_6_by_Google
Waiting for emulator...
emulator: ERROR: x86_64 emulation currently requires hardware acceleration!
Please ensure Intel HAXM is properly installed and usable.
CPU acceleration status: HAX kernel module is not installed!

Finally ended up using the ARM system image and it works fine, though may be a little slow!

No comments:

Post a Comment