1.1 Create Your First Android App

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 28

Android Developer Fundamentals

Hello World

Lesson 1

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 1
Android app ercial 4.0 International License
1.1 Create Your First
Android App

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 2
Android app ercial 4.0 International License
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


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 3
Android app ercial 4.0 International License
Prerequisites
● Java Programming Language
● Object-oriented programming
● XML - properties / attributes
● Using an IDE for development and debugging

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 4
Android app ercial 4.0 International License
Android Studio

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 5
Android app ercial 4.0 International License
What is Android Studio?
● Android IDE
● Project structure
● Templates
● Layout Editor
● Testing tools
● Gradle-based build
● Log Console
● Debugger
● Monitors
● Emulators
This work is licensed under a
Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 6
Android app ercial 4.0 International License
Installation Overview
● Mac, Windows, or Linux
● Requires Java Development Kit (JDK) 1.7 or better from
Oracle Java SE downloads page
● Set JAVA_HOME to JDK installation location
● Download and install Android Studio from
http://developer.android.com/sdk/index.html
● See 1.1 P Install Android Studio for details

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 7
Android app ercial 4.0 International License
Creating Your
First Android App

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 8
Android app ercial 4.0 International License
Start Android Studio

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 9
Android app ercial 4.0 International License
Create a project inside Android Studio

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 10
Android app ercial 4.0 International License
Name your app

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 11
Android app ercial 4.0 International License
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.
This work is licensed under a
Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 12
Android app ercial 4.0 International License
Name your activity
● Good practice to
name main activity
MainActivity and
activity_main layout

● Use AppCompat

● Generating layout
file is convenient
This work is licensed under a
Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 13
Android app ercial 4.0 International License
Android Studio Panes
Layout
Editor

Project
Files

Android Monitors:
logcat: log messages

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 14
Android app ercial 4.0 International License
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. build.gradle—Gradle build files
This work is licensed under a
Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 15
Android app ercial 4.0 International License
Gradle build system
● Modern build subsystem in Android Studio
● Three build.gradle:
○ project
○ module
○ settings

● Typically not necessary to know low-level Gradle details


● Learn more about gradle at https://gradle.org/
This work is licensed under a
Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 16
Android app ercial 4.0 International License
Run your app
1. Run

2. Select virtual
or physical
device
3. OK
This work is licensed under a
Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 17 17
Android app ercial 4.0 International License
Create a virtual device
Use emulators to test app on different versions of Android and form factors.

Tools > Android > AVD Manager or:

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 18
Android app ercial 4.0 International License
Configure virtual device
1. Choose hardware 2. Select Android Version
3. Finalize

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 19
Android app ercial 4.0 International License
Run on a virtual device

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 20
Android app ercial 4.0 International License
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
This work is licensed under a
Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 21
Android app ercial 4.0 International License
Get feedback as your app runs
● As the app runs, Android Monitor logcat shows information
● You can add logging statements to your app that will show up in
logcat.

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 22
Android app ercial 4.0 International License
Logging
import android.util.Log;

// Use class name as tag


private static final String TAG =
MainActivity.class.getSimpleName();

// Show message in Android Monitor, logcat pane


// Log.<log-level>(TAG, "Message");
Log.d(TAG, “Creating the URI…”);
This work is licensed under a
Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 23
Android app ercial 4.0 International License
Android Monitor > logcat pane

1. Log statements in code.


2. logcat pane shows system and
logging messages

● Set filters to see what's important to you


● Search using tags
This work is licensed under a
Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 24
Android app ercial 4.0 International License
Learn more

● Meet Android Studio


● Official Android documentation at developer.android.com
● Create and Manage Virtual Devices
● Supporting Different Platform Versions
● Supporting Multiple Screens

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 25
Android app ercial 4.0 International License
Learn even more

● Gradle Wikipedia page


● Google Java Programming Language style guide
● Find answers at Stackoverflow.com

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 26
Android app ercial 4.0 International License
What's Next?

● Concept Chapter: 1.1 C Create Your First Android App


● Practical: 1.1 P Install Android Studio and Run Hello World

This work is licensed under a


Create your first
Android Developer Fundamentals Creative Commons Attribution-NonComm 27
Android app ercial 4.0 International License
END

This work is licensed under a


Android Developer Fundamentals Storing Data Creative Commons Attribution-NonComm 28
ercial 4.0 International License

You might also like