Building and Debugging the hello-neon Project with VisualGDB

This tutorial shows how to build and debug the hello-neon sample project provided by Android NDK.

Before we begin, ensure that VisualGDB 2.0 or later is installed with the Android Edition.

  1. Start Visual Studio. Go to File->New->Project. Choose VisualGDB->Android Project Wizard. Choose the name and location for the project as you wish.
  2. For this tutorial we are going to copy a sample from the NDK.
  3. If you have not made any Android projects with VisualGDB before, press on 'Configure NDK/SDK locations'. There either browse to the needed tools or development kits or start installing them. screenshot android settings
  4. Press 'Next' in the wizard. Choose the hello-neon sample project. screenshot sample project selection
  5. Press 'Next'. Choose an Android platform 3 or higher. Choose the option of multiple libraries. Press 'Finish'.
    The option 'The JNI Folder folder contains multiple libraries' needs to be selected as the Android.mk file for this project includes the source files separately. screenshot platform selection
  6. Connect a device with armeabi-v7a or start a virtual device with ABI armeabi-v7a (Android 4.0 or later). screenshot avd start
  7. If the app reports that it has no ARMv7 support although the device supports it, modify the Application.mk file to have only the armeabi-v7a target. Note that if you have already built the app, please delete the bin, obj and libs subfolders after you have modified Application.mk. screenshot application mk change
  8. Build the project by going to Build->Build Solution. screenshot building
  9. Launch the project by going to Android->Launch Android App. A successful launch looks as follows i.e. there must be a value for the Neon version. Note that Neon instructions are slower on the emulator. screenshot avd running
  10. Add a breakpoint to line 106 of helloneon.c. screenshot adding a breakpoint
  11. Start debugging. When prompted choose 'Restart the first activity'. screenshot restart activity
  12. When the breakpoint is hit take your time looking at the autos etc. Continue debugging when ready. screenshot stopped breakpoint
  13. Look at the time difference between the Neon and C versions. Now the C version is much slower as stopping at our breakpoint affected the time calculations for it. screenshot avd run affected by breakpoint