Tuesday, October 9, 2012

Enabling the PC Keyboard in Android Emulator

By default the PC Keyboard is not enabled in Android Emulator and it is a pain to use the emulator keyboard. To enable the PC keyboard in emulator you can do the following steps
  • Go to the directory /.android/avd/.avd/ in my case it was C:\Documents and Settings\db2inst1\.android\avd\JellyBean.avd
  • Open the file config.ini
  • Add an entry in the file hw.keyboard=yes
  • Save the file and restart the emulator. Now the PC key board is enabled

Changing hosts file in Google Android Emulator

Now a days lots of our developers are coming with the same question as how do they change the host file in android. So I thougt that it is worth sharing the steps
  • Start Android Virtual Device(AVD) from AVD manager via checking on the check boxes "Launch from Snapshot" &"Save to Snapshot on". Otherwsie the changes you will make via following the process will be ignored and it will take the default host file entries.
  • Run Android\android-sdk-windows\platform-tools\adb remount to make the image as writable
  • Run Android\android-sdk-windows\platform-tools\adb pull /system/etc/hosts c:\android to copy the hosts file to the machine
  • After making changes to the hosts file put it back to android via running Android\android-sdk-windows\platform-tools\adb push c:\android\hosts /system/etc
  • Note that 127.0.0.1 ip will be pointing to the emulator device and 10.0.2.2 will point to the computer where emulator is installed