1.
1 Your first Android app
1
Contents
● Android Studio
● Creating "Hello World" app in Android Studio
● Basic app development workflow with Android Studio
● Running apps on virtual and physical devices
This work is licensed under a Creative
Create your
Android Developer Fundamentals Commons Attribution 4.0 International 2
first Android
License.
Prerequisites
● Java Programming Language
● Object-oriented programming
● XML - properties / attributes
● Using an IDE for development and debugging
3
Android Studio
4
What is Android Studio?
● Android integrated development environment (IDE)
● Project and Activity templates
● Layout editor
● Testing tools
● Gradle-based build
● Log console and debugger
● Emulators
5
Android Studio interface
1. Toolbar
2. Navigation bar
3. Project pane
4. Editor
5. Tabs for other
panes
6
Installation Overview
● Mac, Windows, or Linux
● Download and install Android Studio from
[Link]
● See 1.1 P: Android Studio and Hello World
7
Creating your
first Android app
8
Start Android Studio
9
Create a project inside Android Studio
10
Name your app
11
Pick activity template
Choose templates for
common activities,
such as maps or
navigation drawers.
Pick Empty Activity
or Basic Activity for
simple and custom
activities.
12
Name your activity
● Good practice:
○ Name main activity
MainActivity
○ Name layout
activity_main
● Use AppCompat
● Generating layout
file is convenient
13
Project folders
1. manifests—Android Manifest file -
description of app read by the
Android runtime
2. java—Java source code packages
3. res—Resources (XML) - layout,
strings, images, dimensions,
colors...
4. [Link]—Gradle build files
14
Gradle build system
● Modern build subsystem in Android Studio
● Three [Link]:
○ project
○ module
○ settings
● Typically not necessary to know low-level Gradle details
● Learn more about gradle at [Link]
15
Run your app
1. Run
2. Select virtual
or physical
device
3. OK
16 16
Create a virtual device
Use emulators to test app on different versions of Android and form factors.
Tools > Android > AVD Manager or:
17
Configure virtual device
1. Choose hardware
2. Select Android version
3. Finalize
18
Run on a virtual device
19
Run on a physical device
1. Turn on Developer Options:
a. Settings > About phone
b. Tap Build number seven times
2. Turn on USB Debugging
a. Settings > Developer Options > USB Debugging
3. Connect phone to computer with cable
Windows/Linux additional setup:
● Using Hardware Devices
Windows drivers:
● OEM USB Drivers
20
Get feedback as your app runs
1. Emulator
running the
app
2. Run pane
3. Run tab to
open or close
the Run pane
21
Adding logging to your app
● As the app runs, the Logcat pane shows information
● Add logging statements to your app that will show up in the
Logcat pane
● Set filters in Logcat pane to see what's important to you
● Search using tags
22
The Logcat pane
1. Logcat tab to
show Logcat
pane
2. Log level
menu
23
Logging statement
import [Link];
// Use class name as tag
private static final String TAG =
[Link]();
// Show message in Android Monitor, logcat pane
// Log.<log-level>(TAG, "Message");
Log.d(TAG, “Creating the URI…”);
24
Learn more
● Meet Android Studio
● Official Android documentation at [Link]
● Create and Manage Virtual Devices
● Supporting Different Platform Versions
● Supporting Multiple Screens
25
Learn even more
● Gradle Wikipedia page
● Google Java Programming Language style guide
● Find answers at [Link]
26
What's Next?
● Concept Chapter: 1.1 Your first Android app
● Practical: 1.1 Android Studio and Hello World
27