Debugging an Android x86 application using Intellij

OK, you decided to drop the incredibly slow Android emulator that comes with the official SDK and you are now happily using Android x86… but how do you debug your Android application using Intellij ?

That’s a good question ! (By the way, if you may want to check my last post if you need help running Android x86 in VMWare player).

First, you need to know the IP of your Android x86 VM. To do this, hit ALT-F1 in the VM and use the ‘netcfg’ command to know the IP address given to your eth0 device:

You can then hit ALT-F7 to go back to the Android UI.

Then, in your host PC (the one that is running Intellij), execute the ‘adb connect [ANDROID_X86_IP]” to connect the SDK debugger to your Android x86 VM:

Now go back to Intellij, display your run configuration and make sure that the “show chooser dialog” option is selected:

You are almost done: add a breakpoint in Intellij, launch the application in debug mode and then select your Android x86 device in the “choose device” dialog:

Any question ?


Running Android x86 on VMware player with networking enabled

3 hours ! I’ve lost 3 hours trying to enable network support in an Android x86 VM running in VMWare player. Looks like I was not the only one: just search for “android x86 no network” in Google and you’ll see what I mean.

Anyway, Android x86 is an Android port to the x86 architecture, which means that you can run it on your PC (as opposed to running the slow-as-hell Google Android emulator). Check their website where you can download almost all Android distributions in .iso format.

There are litterally dozens of tutorials that explain how to run Android x86 in Vmware player. This one is one of the best. The most important part is when Vladan tells us to change the “ethernet0.virtualDev” property to “vlance” in the VM configuration file (Read this if you want to understand what the possible values are).

But I couldn’t make it work… do you know why ?

Because the VM configuration file must be modified before you start the VM for the first time. If you start the VM, install Android x86, play with Android and then shutdown the VM to change the configuration file, it’s too late ! (And don’t ask me why because I have no clue).

So, create a new VM making sure that the “Power on VM after creation” option is disabled:

Then, modify the .VMX configuration file (ethernet0.virtualDev = “vlance”) and finally, start the VM and proceed with the installation.


Do Android UI guidelines really make sense ?

Today, I was looking at the “Pure Android” section on the Android developers website. Basically, they are telling you that an Android application must not look like an iPhone application or a Windows phone application.

Here are the UI guidelines:

  • Don’t mimic UI elements from other platforms
  • Don’t carry over platform-specific icons
  • Don’t use bottom tab bars
  • Don’t use right-pointing carets on line items

Don’t use right-pointing carets on line items” ???

They then display a screenshot comparing the Android settings menu and the iPhone settings menu. I don’t know about you, but the iPhone menu really looks more clear to me (in fact, it looks more clear to several people to whom I’ve shown the screenshot).

Now, let’s see how popular desktop applications implement this. First Word 2010:

Then Eclipse:

Finally, Firefox (in french, but you get my point):

In fact, you can open anyone of the applications that you have on your computer and I’m sure that menu items will either end with “>” or “…” to indicate that there are more options to come.

BUT for some unkown reason, the Android team is telling you that this is bad bad bad and that on their platform you should not do this. I don’t know about you, but I will certainly not do it: if everyone else is doing this differently, there must be a reason for that !

Now let me ask you a question: let’s say that your UI decisions makes your application easier to use but do not correspond to the official UI guidelines: what do you do ?


What if Android emulator fails to start

Today I launched the AVD manager, selected my Android virtual device, clicked on  “Start” and… nothing !

OK, why don’t you want to start, you son of your father ?

Launching it from the command line showed the error message:

C:\Program Files (x86)\Android\android-sdk-r16\tools>emulator.exe -avd AVD_for_403

C:\Program Files (x86)\Android\android-sdk-r16\tools>Failed to allocate memory: 8

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

I had previously increased the virtual device memory from 256 to 1024, but for some reason the emulator was not happy with it. Lowering it to 512 solved my issue:

What I don’t understand is that I have 16GB of RAM on my laptop… if someone knows why I cannot allocate 1025MB , I’m interested !