{"id":99,"date":"2014-02-04T17:39:32","date_gmt":"2014-02-04T17:39:32","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=99"},"modified":"2015-07-19T08:20:44","modified_gmt":"2015-07-19T15:20:44","slug":"android-two-libs","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/android\/two-libs\/","title":{"rendered":"Tutorial: Building and Debugging the two-libs Project with VisualGDB"},"content":{"rendered":"<p>In this tutorial we build and debug the two-libs Android ndk sample project. The main idea of the tutorial is to demonstrate how to debug ndk code that is only called at the startup of the app (i.e. OnCreate function).<\/p>\n<p>For this, ensure that <a href=\"\/download\/\">VisualGDB 2.4<\/a> or later is installed with the Android Edition.<\/p>\n<ol>\n<li>Start Visual Studio. Go to File-&gt;New-&gt;Project. Choose VisualGDB-&gt;Android Project Wizard. Choose the name and location for the project as you wish. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/01-newandroidproject.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/01-newandroidproject.png\" alt=\"01-newandroidproject\" width=\"700\" height=\"394\" \/><\/a><\/li>\n<li>Press &#8216;OK&#8217; and choose the &#8216;clone a sample from NDK&#8217; in the wizard. Note that if this is your first VisualGDB Android project, then you may need to configure the NDK\/SDK locations first. Press &#8216;Next&#8217; when done. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/02-clonesample.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/02-clonesample.png\" alt=\"02-clonesample\" width=\"700\" height=\"616\" \/><\/a><\/li>\n<li>For the purpose of this tutorial choose the two-libs sample from the list. Press &#8216;Next&#8217; when done. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/03-selectsample.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/03-selectsample.png\" alt=\"03-selectsample\" width=\"700\" height=\"543\" \/><\/a><\/li>\n<li>Now choose the aimed platform for the project. This sample just needs a min Android version of 1.5. Furthermore make sure the option &#8216;The JNI folder contains multiple libraries&#8217; is selected. Press &#8216;Finish&#8217; to exit from the wizard. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/04-selectplatform.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/04-selectplatform.png\" alt=\"04-selectplatform\" width=\"700\" height=\"543\" \/><\/a><\/li>\n<li>This sample project just has two libs, one calling the other. The function &#8216;first&#8217; just returns a sum of two values. Open the file &#8216;second.c&#8217; and set a breakpoint on the line calling &#8216;first&#8217; by pressing &#8216;f9&#8217; or clicking in front of the line. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/05-setbp.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/05-setbp.png\" alt=\"05-setbp\" width=\"697\" height=\"561\" \/><\/a><\/li>\n<li>Now we build the project by going to Build-&gt;Build Solution. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/06-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/06-build.png\" alt=\"06-build\" width=\"697\" height=\"561\" \/><\/a><\/li>\n<li>Next connect an android device or emulator. Once it is started and connected go to Android-&gt;Debug App Startup. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/07-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/07-debug.png\" alt=\"07-debug\" width=\"697\" height=\"541\" \/><\/a><\/li>\n<li>Next wait for the breakpoint to be hit.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/09-debug2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/09-debug2.png\" alt=\"09-debug2\" width=\"697\" height=\"541\" \/><\/a><\/li>\n<li>Go to the view Autos and change the values of x and y. For this just double-click on the value and write the new value, press &#8216;Enter&#8217; when done.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/10-debug3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/10-debug3.png\" alt=\"10-debug3\" width=\"697\" height=\"541\" \/><\/a><\/li>\n<li>Press &#8216;f5&#8217; to continue running and observe the device screen. The value of the sum is now changed to the values we chose.<\/li>\n<li><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/11-emulator.png\"><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/two-libs\/11-emulator.png\" alt=\"11-emulator\" width=\"567\" height=\"534\" \/><br \/>\n<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial we build and debug the two-libs Android ndk sample project. The main idea of the tutorial is<\/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\/99"}],"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=99"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/99\/revisions"}],"predecessor-version":[{"id":175,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/99\/revisions\/175"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}