Running an App on a Device3:52 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've only run the app in the emulator, but how do we run it on a phone? 0:03 It's usually pretty easy, but it does depend on your phone and 0:08 the computer you're using. 0:12 Even if you don't have a phone to test on, this will still be useful to know. 0:14 On a Mac, PC or Linux computer, 0:18 start by just connecting your phone to the computer with the 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:45 Or maybe you've already installed some software that includes 0:49 the necessary drivers. 0:51 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 testing Android apps. 0:59 I'll also post some helpful notes in the teacher's notes on this page. 1:02 There's a special place in the Android Studio that shows us 1:07 all of our connected devices, including our emulator. 1:10 It's down here in the bottom pane at the top left of the Logcat tab. 1:13 It should show the phone or tablet you just connected, and 1:18 maybe the emulator too, like mine does. 1:21 If your device isn't listed here, then you may need to enable USB debugging. 1:23 Let's take a quick look at how to set that up. 1:28 On your phone or tablet, go to the Android settings 1:31 page, Then scroll all the way to the bottom. 1:33 And open the About Phone or, in my case, the About emulated device section. 1:41 Then scroll to the bottom again, and tap seven times on the build number. 1:46 This may seem a bit weird, but it's what turns on the developer options. 1:54 Now go back and open the developer options section. 1:58 Then scroll down to USB debugging and make sure that it's turned on. 2:04 And hit OK to allow USB debugging. 2:11 You might get a notification on the phone that USB debugging is now activated. 2:15 If your device is listed here like mine is, 2:21 then that means you're ready to run apps on your device. 2:23 We can run our app using the same run button or 2:27 keyboard shortcuts that we've been using. 2:29 I'll use the Run button. 2:31 Wait, we don't see the device chooser. 2:34 If you don't see the device chooser, we can always click up here. 2:37 And then select Edit Configurations. 2:41 Then, uncheck the Use same device for future launches check box. 2:45 And click OK. 2:50 Then you'll need to stop the app running on the current device, and 2:53 then when you run the app again, we get the device chooser. 2:57 This list shows the device, its name, and the version of Android that it's running. 3:01 Now select the device you connected, for 3:06 me it's this one, and click OK to launch the app. 3:09 Then if you see a warning about Instant Run, 3:14 just click Proceed without Instant Run. 3:16 Once the app loads, we should see some information here in Logcat. 3:20 And if we look to the top left, we can see that it's running on our device. 3:26 We can also click over to this Run tab, and 3:31 we can see information about how the app was loaded onto the device. 3:35 If there were any problems, you may see errors here or on the Logcat. 3:39 The app should start automatically on the phone. 3:45 And success! 3:47 Now you can show off your app to your friends and family. 3:49
You need to sign up for Treehouse in order to download course files.Sign up