{"id":95,"date":"2014-02-04T17:39:32","date_gmt":"2014-02-04T17:39:32","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=95"},"modified":"2015-08-07T15:09:51","modified_gmt":"2015-08-07T22:09:51","slug":"android-ouya","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/android\/ouya\/","title":{"rendered":"Creating C++ OpenGL apps for OUYA with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to build and debug a simply OpenGL application for the OUYA game console using VIsual Studio. We will create a project based on the <strong> San-Angeles<\/strong> sample that is included with Android NDK.<\/p>\n<p>Before you begin, please install <a href=\"\/download\"> VisualGDB 4.0<\/a> or later (ensure that &#8220;Android Edition&#8221; is checked in the installer).<\/p>\n<ol>\n<li>Connect your OUYA console to your development machine over USB:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/ouya500.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/ouya500.png\" alt=\"ouya500\" width=\"500\" height=\"444\" \/><\/a><\/li>\n<li>Download, unpack and start <a href=\"\/UsbDriverTool\/\"> UsbDriverTool<\/a>. Select &#8220;OUYA&#8221; in the device list, right-click, and select &#8220;Install Android ADB Driver&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/usbdrivertool.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/usbdrivertool.png\" alt=\"usbdrivertool\" width=\"609\" height=\"450\" \/><\/a><\/li>\n<li>When asked whether you want to update adb_usb.ini, select &#8220;yes&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/adbini.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/adbini.png\" alt=\"adbini\" width=\"482\" height=\"171\" \/><\/a>If you encounter problems with finding your device, try installing the driver manually according to the official <a href=\"https:\/\/devs.ouya.tv\/developers\/docs\/setup\">OUYA USB driver instructions<\/a> for Windows if you have not already.<\/li>\n<li>Start Visual Studio. Select File-&gt;New project-&gt;VisualGDB-&gt;Android Project Wizard. Select a name and location for the project, click on &#8216;OK&#8217;.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/01-newproject.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/01-newproject.png\" alt=\"01-newproject\" width=\"700\" height=\"394\" \/><\/a><\/li>\n<li>If this is your first time making an Android project with VisualGDB, you are asked to configure the locations for the Android tools beforehand. Click on &#8216;Configure NDK\/SDK locations&#8217;.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/02-notools.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/02-notools.png\" alt=\"02-notools\" width=\"700\" height=\"610\" \/><\/a><\/li>\n<li>As you already installed the Android SDK when installing the USB driver, detect or browse to the Android SDK and Java installation directories. Specify the Android NDK and ant installation directories or install them. Press &#8216;OK&#8217; when done.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/03-androidtools.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/03-androidtools.png\" alt=\"03-androidtools\" width=\"640\" height=\"229\" \/><\/a><\/li>\n<li>Choose &#8216;Clone a sample from NDK&#8217; and press on &#8216;Next&#8217;.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/04-clonesample.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/04-clonesample.png\" alt=\"04-clonesample\" width=\"700\" height=\"610\" \/><\/a><\/li>\n<li>Choose &#8216;san-angeles&#8217; and press on &#8216;Next&#8217;.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/05-sanangeles.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/05-sanangeles.png\" alt=\"05-sanangeles\" width=\"700\" height=\"610\" \/><\/a><\/li>\n<li>Choose &#8216;Android 4.1&#8217; and press on &#8216;Finish&#8217;.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/06-androidplatform.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/06-androidplatform.png\" alt=\"06-androidplatform\" width=\"700\" height=\"610\" \/><\/a><\/li>\n<li>Now the project has been created. Next we make some fixes to be able to build the project. Right-click on both <strong>app-linux.c <\/strong>and <strong>app-win32.c<\/strong> and choose &#8216;Exclude from Project&#8217;.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/08-exclude.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/08-exclude.png\" alt=\"08-exclude\" width=\"695\" height=\"615\" \/><\/a><\/li>\n<li>Build the project Build-&gt;Build Solution.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/09-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/09-build.png\" alt=\"09-build\" width=\"695\" height=\"615\" \/><\/a><\/li>\n<li>Now make sure the OUYA is started and connected to the development computer via USB and that a screen is connected to OUYA.<\/li>\n<li>Start debugging. You will see the san-angeles example running on the sceen connected to OUYA:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/o01-sanangeles.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/o01-sanangeles.jpg\" alt=\"o01-sanangeles\" width=\"700\" height=\"393\" \/><\/a><\/li>\n<li>Set a breakpoint in the <strong>_getTime<\/strong> function in <strong>app-android.c<\/strong> to test that breakpoints are working.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/10-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-13\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/10-debug.png\" alt=\"10-debug\" width=\"695\" height=\"615\" \/><\/a><\/li>\n<li>The breakpoint will hit, however after 5 seconds the app will be terminate.. This happens because OUYA\u00a0 detects<br \/>\nthe &#8216;activity not responding&#8217; condition and believes the app<br \/>\nhas frozen. We will now fix it by telling OUYA that the<br \/>\ncurrent app is being debugged. In the main OUYA menu select<br \/>\n&#8220;manage&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/o02-manage.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/o02-manage.jpg\" alt=\"o02-manage\" width=\"700\" height=\"440\" \/><\/a><\/li>\n<li>In the &#8220;manage&#8221; menu select &#8220;Notifications&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/o03-notifications.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-15\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/o03-notifications.jpg\" alt=\"o03-notifications\" width=\"700\" height=\"398\" \/><\/a><\/li>\n<li>On the next screen select &#8220;USB debugging connected&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/o04-usbdebug.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-16\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/o04-usbdebug.jpg\" alt=\"o04-usbdebug\" width=\"700\" height=\"407\" \/><\/a><\/li>\n<li>Scroll down until you see &#8220;select debug app&#8221; and select this item:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/o05-select.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-17\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/o05-select.jpg\" alt=\"o05-select\" width=\"700\" height=\"402\" \/><\/a><\/li>\n<li>Select the activity you are intending to debug. Note that the activity name is not equal to the application name:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/o06-activity.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-18\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/android\/ouya\/o06-activity.jpg\" alt=\"o06-activity\" width=\"700\" height=\"409\" \/><\/a><\/li>\n<li>Once the debugged activity is selected, start debugging again and let VisualGDB stop on a breakpoint. You will notice that OUYA will not terminate you app and you will be able to debug it reliably.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to build and debug a simply OpenGL application for the OUYA game console using VIsual Studio.<\/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],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/95"}],"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=95"}],"version-history":[{"count":2,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/95\/revisions"}],"predecessor-version":[{"id":488,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/95\/revisions\/488"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}