Google has made it unnecessarily complicated to write Android apps under Windows for C++ developers who are used to Visual Studio. Hopefully this posting makes it easier.

This article is about setting up your Android development environment in combination with Visual Studio and WinDBG for mobile systems beta. The result is that you can create and debug Android projects from within Visual Studio on emulator and the actual device (that doesn’t need to rooted). Those project files are kept in sync with the original NDK build files (Android.mk etc) so they are compatible with the command-line tools. In other words, you can still use ndk-build and ant. If you are a happy Eclipse user, this posting isn’t for you.

There is an open source project called vs-android that integrates Android with Visual Studio, but it doesn’t support debugging as far as I know.

Before we can install WinGDB we need to have the NDK in working order. Google don’t provide a single installer for their NDK. Instead they ask developers to gather all information and installers from various websites. Many things can go wrong this way. On top of that, their 64bit NDK installer has a bug that doesn’t find the Java installation path until you hit “back/next”. Steps 1 to 6 below deals with installing the NDK.

If you already have a working recent NDK environment you can skip to step 7 for WinGDB.

1) Download the JDK from the Oracle website after accepting the agreement, the current version is jdk-6u26-windows-x64.exe

Install the JDK to C:\Program Files\Java\jdk1.6.0_26\ and install JRE to C:\Program Files\Java\jre6\ and make sure java.exe is in your path.

2) Download Apache Ant apache-ant-1.8.2-bin.zip from the http://ant.apache.org/ website and
unzip it to c:\android\apache-ant-1.8.2-bin\

3) Download Android SDK from http://developer.android.com/sdk/index.html, for example this recent installer installer_r12-windows.exe

Run the installer.
It might complain that the JDK is not found:

Just hit the Back button and Next:

Hit next and choose your destination path. I changed it from
C:\Program Files (x86)\Android\android-sdk to C:\Android\android-sdk to keep the SDKs together.

4) Start the SDK manager

Your choice of packages depends which Android versions you target for your App. You can just select the default set, it might take a while to download though.

5) Download the Android NDK android-ndk-r6-windows.zip and unzip it in c:\android.

6) Install Cygwin from http://cygwin.com/install.html using setup.exe

Install Cygwin to the default location, c:\cygwin and select a mirror

Make sure to select the ‘make’ tool by searching for ‘make’ and enabling ‘install’ for the ‘Devel’ packages:

7) Download WinGDB from http://www.wingdb.com/wgMobileEdition.htm, currently the beta version is WinGDB-2.0-b1006-mse.msi

8)Run the WinDBG installer

Then configure WinGDB using the WinGDB preferences tab in Visual Studio

and set the directories where you install/unzipped the packages in previous steps:

9) Create a new Android project in Visual Studio

and choose the name and target

Once the project is created, change some project properties

and change the debug target to device. You can also leave it to use the emulator, but I find it too sluggish.

10) Connect your Android device and make sure the USB drivers are installed. For my Asus TF101 the USB drivers were automatically installed

Enable USB debugging on your Android device, put some breakpoint in your main.cpp and hit F7 or F5 within Visual Studio and if all goes well:

If the connection doesn’t work, you could try disabling your firewall and/or anti-virus scanner. Another option is to enable the Pipe method instead of TCP/IP:

WinGDB also supports import of existing Android projects, but your mileage might vary. If it works for you (or not), please leave a comment.

Note that WinGDB mobile edition is still in beta, so please report problems to forums. I ran into a few issues that hopefully get sorted in the final version of WinGDB, but I find the free beta already useful enough to try it out.