Debugging vs-android projects with VisualGDB

本文介绍如何使用Visual Studio调试由vs-android创建的原生Android项目。包括设置项目为可调试、安装VisualGDB、配置AndroidManifest.xml文件等步骤,并演示了如何设置断点以及启动调试会话。

This tutorial explains how to debug native Android projects made with vs-android in Visual Studio

  1. First ensure that your vs-android project can be built properly. If you cannot make it work, please consider using VisualGDB Project wizard instead. In this tutorial we will use the san-angeles project from the vs-android samples.
  2. Download the latest VisualGDB. If you are using custom installation, ensure that Android Edition is selected for installation:
  3. Open Visual Studio, click at Android->Setup SDK/NDK locations. Enter the locations of your Android tools or use the "Detect" buttons to try detecting them automatically:If you want to debug your vs-android projects with F5, you need to enable this feature here by pressing "Add Support".
  4. Open your vs-android project (in this example we use the san-angeles sample). Open theAndroidManifest.xml file inside the AndroidApk folder and set the android:debuggable attribute to "true":
     <application android:label= "@string/app_name"
                  android:debuggable= "true">
         <!-- Your activities are listed here -->
    </application>
  5. In this tutorial we set a breakpoint inside the drawGLObject() function. You can set breakpoints anywhere in the code before and during debugging, just like in normal Visual Studio projects.
  6. Select Android->Debug Android App in Visual Studio:If the debug commands are not displayed, please select your project as startup project in the solution.
  7. If you encounter a message about inconsistent signature, please use the Android->Remove App from device command.
  8. If you are debugging the project for the first time, VisualGDB will detect that gdbserver is missing and suggest auto-installing it. Please click "yes", then rebuild your project with Build->Rebuild Solution.If you do not rebuild the solution, gdbserver will not be put inside the apk file and debugging won't be possible.
  9. Click Android->Debug Android App again. VisualGDB will begin deploying your project and preparing the debugging session:
  10. If you have previously set a breakpoint at a location that gets executed, your breakpoint will be triggered:
  11. Go to Project Properties, select Debugging page and ensure that you have VisualGDB Android Debugger selected:Note that the Android Debugger won't appear in the list unless you enable it from the Setup NDK/SDK locations dialog.
  12. You can configure VisualGDB-specific settings for your vs-android projects by right-clicking on the project and selecting VisualGDB Project Properties:

Congratulations! You can now debug your app. You can also setup Visual Studio to use the original NDK build system by following this tutorial.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值