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!

Monday, June 08, 2015

Windows 8.1 Pro on a USB Drive

Xubuntu and Kodi on i3 NUC was nice. But I often run into issues and is quite time consuming to get things straight (perhaps because I am not a Linux expert too!). Anyway, everything was configured, up and running with Xubuntu 14.10 and the new 15.04 release came and messed things up. The sound doesn't work after the upgrade, I see only a Dummy Output! Searching on forums, I see many people reporting this issue, but no solution than to downgrade. Also had some HDMI sync issue every time I start my home theater receiver (keep the NUC running 24x7) too and was getting tired of linux on NUC! Intel provide very few drivers for linux. So it was time to give Windows a try :-)

Usually windows is very easy to setup, but I had a major challenge! I don't have a hard disk and Windows doesn't support installing to USB drives (or even portable HDD connected via USB). Btw, if you want to create a bootable Windows installer on USB, use the rufus utility and the Windows install ISO. It is like the LiLi for windows :-)

Thanks to Google, found that there is a Windows to Go option, though officially supported only for Enterprise edition. You can get it to work for other editions using a utility called WinToUSB. Though it seemed to save the day, Windows 8.1 Pro was not booting up, it was stuck on the logo with the progress spinning for ever! Finally got it to work using the VHD (vs Legacy) option supported by WinToUSB while creating the usb installer.

Now I got Windows on my NUC and everything works quite well, especially with all the wonderful intel drivers! Kodi works quite well too (Note: use WASAPI instead of DirectSound for clean unadulterated sound)

Note: You need to activate the windows with a valid key

Clone your bootable usb drive in minutes!

I have an Intel i3 NUC which runs Xubuntu full install on a Sandisk Extreme 16GB USB 3.0 stick. It doesn't have a hard disk :-) Everything was working fine (mostly use it to share hdd, printer etc and also as a media player - Kodi/XMBC), until it ran out of space trying to upgrade from Ububtu 14.10 to 15.04. So I bought a new Sandisk Ultra Fit 64GB USB 3.0 and was finding it hard to setup everything from scratch and reconfigure/customize it. I wanted to give Kubuntu a try, but install failed as it was not able to partition the USB drive (don't remember, but I think I was able to boot and install Xubuntu into same drive). I didn't want to waste anymore time and just wanted to get things going quickly. Was looking for easy ways to clone and found this!

There is a command called dd and using it I could clone my usb disk and boot from the new one in about 10-15 minutes!

The syntax is as follows:
dd if=/dev/sdc of=/dev/sda
Make sure you give the whole device (sdc vs sdc1) and not a partition. Also double check the source and target device names (sda/sdb/sdc) before you start the command.

Couple of things to keep in mind:

  • Target has to be same size or larger than source. If larger you can resize partitions later
  • boot record will be copied only if you clone whole device vs a partition
  • You can use the UI (eg: Disks) or sudo fdisk -l to find out the device names
  • You can optimize transfer by setting block sizes, eg: sudo dd if=/dev/sdx of=/dev/sdy bs=8M



You can see that after the operation, I have the same partitions from the 16GB drive on my new 64GB one. To resize existing partition, I removed the swap, resized main (leaving some space for swap at the end) and then created swap at the end. This was done using GParted.

Hope it saves many hours or days of yours, have fun!