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 fig3

Figure 3. Available device emulators in the New Emulator window

I selected Nexus 4 and clicked Next. The resulting System Image dialog box invited me to select a system image. I clicked the Other Images tab followed by IceCreamSandwich (without the Google APIs).

androidstudiop3 fig4

Figure 4. Using the emulator to run the app on a non-Intel platform

Once you've got your own emulator set up, you'll need to click the Download link to download the image, which isn't installed by default. After accepting the license agreement, click Next. The component installer starts downloading the components.

androidstudiop3 fig5

Figure 5. Click Finish when installation finishes and this button is highlighted

Select IceCreamSandwich in the resulting list followed by Next. You can now configure an AVD.

androidstudiop3 fig6

Figure 6. Configure the AVD as appropriate and click Finish

Select Run 'app' from the Run menu or select the green triangle icon on the tool bar. Once more, Android Studio responds with the Select Deployment Target dialog box. This time, highlight the Nexus 4 API 14 entry and click OK.

The emulator first presents a splash screen. After a few moments, this screen is replaced by a frame window for the Nexus 4 device.

androidstudiop3 fig7

Figure 7. The emulated Nexus 4 device's frame window

It can take a long time for the emulator to finish initializing. In my case, it took more than 10 minutes, which was too long for Android Studio: it gave up and presented the following error message:

Error while waiting for device: Timed out after 300 seconds waiting for emulator to come online.

If you encounter this error, get yourself a cup of coffee and read a magazine. When you come back, you should observe the emulated device's startup screen.

androidstudiop3 fig8

Figure 8. Start up screen displayed in an emulated Nexus 4 device's frame window

Dismiss the startup screen and navigate to the app launcher screen. You will not yet see the W2A app icon on this screen.

androidstudiop3 fig9

Figure 9. The emulated Nexus 4 device's app launcher screen

Run the app a second time. If all goes well, you'll see messages about the app being installed. Also, you'll see the default Android icon for the W2A app on the app launcher screen.

androidstudiop3 fig10

Figure 10. The W2A icon appears in the lower-right corner of the app launcher screen

You don't have to click the icon because W2A automatically starts running. You'll observe the green Android logo and a button labeled Animate.

 

Previous Page  1  2  3  4  Next Page 

Sign up for CIO Asia eNewsletters.