Subscribe / Unsubscribe Enewsletters | Login | Register

Pencil Banner

Android Studio for beginners, Part 3: Build and run the app

Jeff Friesen | Aug. 24, 2016
Build your app with Gradle, then run it on an Android device emulator or Kindle Fire tablet

androidstudiop3 fig11

Figure 11. Click the button to animate the image

Running the app on the Amazon Kindle Fire HD tablet

Running an app via a slow emulator can be very frustrating. One solution is to use faster emulation software, such as GenyMotion's Android emulator. Another solution is to use an actual Android device.

Genymotion and Android Studio

If you're interested in using GenyMotion with Android Studio, you might want to check out Francesco Azzola's Java Code Geek's blog post, "Android Studio with android alternative emulator:Genymotion."

A few years ago, I purchased a first-generation 2012 Amazon Kindle Fire HD 7" tablet, which runs Android 4.0.3 (API Level 15). I use this tablet to run Android apps that don't require the latest Android APIs.

While researching how to use my Kindle Fire tablet with Android Studio, I found two useful guides from Amazon: "Setting Up Your Development Environment for Fire Tablets" and "Connecting Your Fire Tablet for Testing." I'll summarize the process of connecting a Kindle Fire device to Android Studio, but refer to these guides if you need more information.

First, if you're a Windows user like me, you'll need to start by uninstalling the non-ADB (Android Debug Bridge) driver that's installed when your Kindle Fire tablet is connected to your development computer, without first enabling ADB. Then you'll install Amazon's USB driver.

Next, download the Kindle Fire USB driver. The downloaded ZIP archive contains a KindleDrivers.exe application.

Execute KindleDrivers.exe and follow the resulting instructions. I ended up with a C:\Program Files (x86)\\Fire_Devices\Drivers directory containing the necessary driver files.

After installing the drivers, you'll need to enable ADB on your tablet. Then, you'll connect the tablet to your development computer. See the Amazon guide if you need additional instructions for connecting your tablet to Android Studio.

Once you have everything set up, start Android Studio, load the W2A project, and run the W2A app. This time, the Select Deployment Target dialog should show an Amazon KFTT entry in the Connected Devices section. Select this entry and click OK. Android Studio will respond by directing Gradle to build the app.

Despite various error messages about various API types not being found, Android Studio successfully installed the APK on my device and automatically ran the app.

Figure 12 shows the W2A app icon on the app launcher screen.

androidstudiop3 fig12

Figure 12. The W2A app icon is located near the lower-right corner

Figure 13 shows the W2A app running.

androidstudiop3 fig13

Figure 13. Click Animate to perform the animation

Conclusion to Part 3

You've written, built, and run your first Android Studio application, so you might be wondering what's next. For now, I suggest you experiment with what you've learned. Use the examples and source code from the three beginner tutorials to develop a new project of your own. Keep your projects simple while you learn the ins and outs of working with Android Studio and its built-in features, but do challenge yourself to experiment.


Previous Page  1  2  3  4  Next Page 

Sign up for CIO Asia eNewsletters.