Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Debugging the Android App7:38 with Heath Hodgert
This video will be focused on making sure our new project can be deployed and ran on an Android platform. We'll discuss configuration settings for the Android project and Android SDK tools. There are also many emulator choices to discuss although we'll start with the Android supplied emulator.
- adb -- Android Debug Bridge a command line tool for Android debugging
Android Emulator Choices:
- Android Emulator, installed by default that covers all API but can be slow
- Microsoft Android Emulator, runs well but does not support the latest API
- GenyMotion, great emulator with many options and APIs but uses VirtualBox which can conflict with other VMs, and costs money
This video will be focused on getting our app up and running and 0:00 debugging our new project on the Android platform. 0:04 We will discuss configuration settings for the Android project and Android SDK tools. 0:08 There are many emulators choices that you can read about in the teacher's notes, but 0:15 we'll use the Android supplied emulator. 0:20 Now that we have written the code we need for 0:23 the Android app, let's make sure our environment is set up so we can debug it. 0:25 First thing to remember is we have multiple platforms, so 0:30 we need to let the ID know which we want to build. 0:34 In the toolbar, choose the Android project as your start up project. 0:37 You can also right-click on the Android project and Set as StartUp Project. 0:42 So now we should be able to build and deploy the app. 0:48 We need to decide how we will interact with the app. 0:51 You can use a physical device or an emulator. 0:55 The simplest solution is to plug in your Android device with a USB cable. 0:59 When you do this, you'll see that it shows up on the run button in the toolbar. 1:03 The other option is to use an emulator. 1:08 Emulators are great for testing different Android versions and screen sizes. 1:11 I also like emulators because I can interact with them 1:16 with keyboard and mouse. 1:19 Emulators also let you change OS version, screen size, so 1:21 you don't have dozens of Android devices hanging around. 1:26 Although, I'll warn you the emulators don't always work like physical devices. 1:30 Some of the hardware features of the physical device can be emulated, 1:35 but sensor displays and memory can behave very differently. 1:39 Emulators can do multiple touch gestures like pinch and 1:44 zoom but can't complex multi-touch gestures. 1:48 Some OEMs will also change default behavior like HTC One home screen 1:52 slides up and down instead of left and right. 1:57 The emulator choices are listed in the teacher's notes with a brief description. 2:01 We'll use the default Android emulator that comes with the SDK. 2:06 If we open the drop down in the run button, you can see our options. 2:11 Select the Visual_Studio_android-23_x86_phone, 2:17 which was installed when you add the mobile components to the Visual Studio. 2:21 Clicking the run button will launch the emulator, deploy our app, and 2:28 launch it in debug mode. 2:32 The first time Visual Studio launches the emulator and tries to deploy the app, 2:35 it may stall because it takes a while for the emulators to start. 2:39 You can cancel the build and start again because the emulator will not have closed. 2:43 Now click the run button and it will build and open our project in the emulator. 2:55 Tap the entry field and type in a number. 3:15 Tap the calculate button and 3:25 a pizza count will show in the text view below the button. 3:27 Now that we have our project running for Android, 3:31 we will take a look at some of the debugging features. 3:33 Clicking the Stop button will stop your debug session, and 3:37 close the app on the device. 3:40 It's important to understand the solution configuration and how they are used. 3:42 The template we chose will have all the basic configurations, but 3:47 let's look at them and see what we have. 3:51 Open the Configuration Manager from the toolbar or 3:54 by right-clicking on the solution and selecting Configuration Manager. 3:56 The default configuration is Debug on Any CPU. 4:02 You can see that the PCL and the android project are built and 4:06 the Android one is set to deploy. 4:10 The Release configuration is the same but 4:14 it's set up to remove debug symbols and link libraries to reduce 4:17 the size of the app, which we will see in the project properties. 4:21 There are a few other platforms to find here, but we don't need them for Android. 4:26 When we get to the iOS configurations, we'll talk about them. 4:31 Android project properties can be accessed by right-clicking the Android project or 4:35 projects menu. 4:41 We will briefly go through each section of the properties and 4:43 I'll point out important properties. 4:46 In the application section, the Default Namespace, 4:49 you'll notice it has a dot Droid instead of Android. 4:52 This is to prevent Namespace conflicts with native Android frameworks. 4:56 Compile using Android version determines which installed compiler to use. 5:01 The Android manifest section is important for 5:08 releasing our app to the store and for permissions. 5:10 The Minimum Android Version determines which APIs are available and 5:13 which platforms that our app can run upon. 5:17 The required permissions lets you request access to different features like 5:21 internet, camera or microphone. 5:26 The Android Options section lets us configure compile features. 5:36 The link of properties can significantly reduce the size of your app. 5:41 But it can cause problems if it's too aggressive 5:46 because it can drop libraries it doesn't think it needs. 5:48 Linking set to none will not try to link and it's best for debugging. 5:52 The SDK assembly's only options will link basic class libraries but 5:58 not user assemblies, which is used for 6:03 release configuration to reduce the size of the app. 6:06 The Build, Build Events, and Reference Paths sections 6:10 are MSBuild features and are like any other Visual Studio projects. 6:14 And we can ignore them for now. 6:19 Now, let's look at some of the Android tools. 6:21 The Android Emulator Manager is an external app 6:24 that comes with the Android SDK. 6:26 Visual Studio will install a few basic emulators, but 6:29 if you want the latest or an older API version, you can create them here. 6:33 The Android SDK Manager is also an external app, 6:39 which manages which SDK components you have available. 6:42 There are frequent updates to these SDKs, so if it's important 6:46 to your project to have the latest features you can change it here. 6:51 The Android Device Monitor and Device Log are great tools for 6:56 monitoring your emulator or 6:59 any connected Android device, even when you're not debugging from Visual Studio. 7:01 The Android Adb Command Prompt is useful when you want to interact with devices or 7:07 emulators. 7:13 The Adb server is what manages all the running or 7:14 connected emulators and devices. 7:17 Sometimes you need to reset the Adb servers, especially when your app crashes. 7:20 We have launched the app on Android and 7:26 looked at the configurations, tools, and properties. 7:28 Next, we'll focus on our iOS code and development environment. 7:33
You need to sign up for Treehouse in order to download course files.Sign up