{"id":92,"date":"2014-02-04T17:39:32","date_gmt":"2014-02-04T17:39:32","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=92"},"modified":"2015-07-19T08:18:13","modified_gmt":"2015-07-19T15:18:13","slug":"android-native-activity","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/android\/native-activity\/","title":{"rendered":"Debugging the native-activity project with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to build and debug the <strong> Native-activity<\/strong> sample provided with Android NDK.<\/p>\n<p>Before you begin, please install <a href=\"\/download\"> VisualGDB 2.0<\/a> or later (ensure that &#8220;Android Edition&#8221; is checked in the installer). If you are not familiar with VisualGDB, please first go through the <a href=\"\/tutorials\/android\">Android Quickstart tutorial<\/a>.<\/p>\n<ol>\n<li>Start Visual Studio. Select Android-&gt;AVD Manager to start Android Emulator.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-activity\/01-avd.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-activity\/01-avd.png\" alt=\"01-avd\" width=\"680\" height=\"608\" \/><\/a><\/li>\n<li>If you already have a virtual Android device based on version 2.3.3 or later, start it. Otherwise, create a new virtual device (<strong>versions before 2.3.3 do not support native activities!<\/strong>).<\/li>\n<li>Go back to Visual Studio. Select File-&gt;New project-&gt;VisualGDB-&gt;Android Project Wizard.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-activity\/02-newprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-activity\/02-newprj.png\" alt=\"02-newprj\" width=\"700\" height=\"394\" \/><\/a><\/li>\n<li>Enter a path for the new project and specify an arbitrary project name. Press &#8220;OK&#8221;.<\/li>\n<li>Select &#8220;Clone a sample from NDK&#8221; and press &#8220;Next&#8221;.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-activity\/03-clone.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-activity\/03-clone.png\" alt=\"03-clone\" width=\"699\" height=\"616\" \/><\/a><\/li>\n<li>Select &#8220;native-activity&#8221; from the sample list. Press &#8220;next&#8221;.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-activity\/04-native-activity.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-activity\/04-native-activity.png\" alt=\"04-native-activity\" width=\"700\" height=\"543\" \/><\/a><\/li>\n<li>Select &#8220;Android 2.3.3&#8221; from the platform list. Press &#8220;next&#8221;.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-activity\/05-platform.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-activity\/05-platform.png\" alt=\"05-platform\" width=\"700\" height=\"508\" \/><\/a><\/li>\n<li>Build your project by selecting &#8220;Build-&gt;Build Solution&#8221;.<\/li>\n<li>Open the main.c file and set a breakpoint after the &#8220;Process the event&#8221; comment.<\/li>\n<li>Start debugging by selecting Android -&gt; Debug Android App.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-activity\/06-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-activity\/06-debug.png\" alt=\"06-debug\" width=\"680\" height=\"608\" \/><\/a><\/li>\n<li>Wait until VisualGDB deploys the app, launches it and attaches to it.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-activity\/07-launch.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-activity\/07-launch.png\" alt=\"07-launch\" width=\"680\" height=\"608\" \/><\/a><\/li>\n<li>After VisualGDB attaches to the app, the breakpoint should hit. If this does not happen, go to the emulator and click on the screen. Then go back to Visual Studio.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-activity\/08-inspect.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/native-activity\/08-inspect.png\" alt=\"08-inspect\" width=\"680\" height=\"608\" \/><\/a><\/li>\n<li>You can now use the usual Visual Studio windows (e.g. <strong>call stack<\/strong> or <strong>watch<\/strong>) and commands (e.g. <strong>step over<\/strong>) to debug your program.<\/li>\n<li>To finish debugging, press Shift+F5.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to build and debug the Native-activity sample provided with Android NDK. Before you begin, please install<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[87],"tags":[31,45],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/92"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=92"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/92\/revisions"}],"predecessor-version":[{"id":172,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/92\/revisions\/172"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=92"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=92"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=92"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}