Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Running an App on a Device3:31 with Ben Deitch
Thus far we have been running our apps with the emulator from within Android Studio. In this video we'll see how we can launch our apps directly to a device!
- Using Hardware Devices - How to test your app on a real phone or tablet
- Connecting Smartphone to Laptop Running Windows 8 - Instructions from a Treehouse student on how to run apps on your phone from Windows 8
- What Employers Are Looking for in a Junior Android Dev - Some advice on getting a job as a junior Android developer
There's one very important thing we haven't talked about yet. 0:00 So far, we have only run the app in the emulator. 0:03 But how do we run it on a phone? 0:06 It's usually pretty easy. 0:08 But it does depend on your phone and the computer you're using. 0:09 Even if you don't have a phone to test on, this will still be useful to know. 0:13 On a Mac, PC, or Linux computer, 0:17 start by just connecting your phone to the computer with a USB cable. 0:20 You may need to disconnect the USB cable from your charging adapter. 0:24 If you're using a Windows or Linux computer, this is where it can get tricky. 0:28 You need the appropriate device drivers for your phone. 0:32 Some standard drivers are included in the Android development bundle we're using. 0:35 But in some cases, you'll be prompted to download and 0:39 install the drivers when you connect your phone. 0:42 Or you might need to visit the website of the manufacturer to get the right drivers. 0:44 Or maybe you've already installed some software that includes the necessary 0:49 drivers. 0:52 Each device is different, and sometimes it can be tricky. 0:53 But if you have any trouble, check the community or 0:56 Google how to connect your specific device for Android apps. 0:58 I'll also post some helpful notes in the teacher's notes on this page. 1:02 There's a special place in Android studio that shows us all of our connected devices 1:07 including our emulator. 1:11 It's down here in the bottom pane at the top left of the Logcat tab. 1:12 It should show the phone or tablet you've just connected and maybe the emulator too. 1:17 If your device isn't listed here, then you may need to enable USB debugging. 1:22 Let's take a quick look at how to step that up. 1:26 On your phone or tablet, go into the Android Settings page. 1:30 Then scroll all the way to the bottom, and open the About phone section. 1:35 In my case, it says About emulated device. 1:40 Then scroll down to the bottom again, and tap seven times on the Build number. 1:44 In my case, I've already done this. 1:50 But once you click seven times, it will turn on the developer option section. 1:52 So you can go back and open the developer option section. 1:57 Once in here, you can scroll down to USB debugging, And 2:02 make sure that it's turned on. 2:07 You might get a notification on the phone that USB debugging is now activated. 2:10 If your device is listed here, 2:16 like mine is, that means you're ready to run apps on your device. 2:17 We can run our app using the same run button or 2:21 keyboard shortcuts that we've been using. 2:24 However, if you've checked the check box to use the same device for 2:26 future launches, you'll want to come in here, choose Edit Configurations, 2:29 and then uncheck this check box, and then hit OK. 2:35 Now, when you try to run the app, you'll get the device chooser, and 2:41 you can pick your own device instead of the emulator. 2:46 So select the device you connected and click OK to launch the app. 2:49 And I'll choose to Proceed without Instant Run. 2:54 Once the app loads, we should see some information here in Logcat. 2:59 And if we look to the top left, we can see that it's running on our device. 3:03 We can also click on this Run tab. 3:08 And we can see information about how the app was loaded onto the device. 3:11 If there were any problems, you may see some errors here on the Run tab. 3:18 The app should start automatically on the phone, and success. 3:23 Now, you can show off your app to your friends and family. 3:28
You need to sign up for Treehouse in order to download course files.Sign up