Android App Development : Introduction

Getting a hang of Android Studio

Official Intro

Installation

Official Documentation

Requirements

Min 4GB RAM
Min 100GB free hard disk

Download

https://developer.android.com/studio

Install

Keep using default options, make sure C:\ drive has enough space(eg: 500GB free)

Configure Android Studio

https://developer.android.com/studio/intro/studio-config

JDK Version

Install Java

Install the latest Java for windows 64 from oracle link, which ill install it inC:\Program files folder.

The installer from Java site , is installing it in Program files (x86)

Set JAVA_HOME Environment Variable

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
set the environment variable JAVA_HOME as C:\Program Files\Java\<jdkversion>

PS: Generated apks are stored in in \app\build\outputs\apk\debug\app-debug.apk

Create New Project

Choose Empty Project

Options

Name:
Package:
Save Location : File location in your computer
Langiage: Java
Minimum SDK API: 24(Android 7)

Hit Finish

Project Structure

Official Documentation

The Android project structure on disk differs from this flattened representation. To see the actual file structure of the project, select Project instead of Android from the Project menu.

File Structure of Android Project

.git
.gradle
.idea
build.gradle(Project): Top-level build file where you can add configuration options common to all sub-projects/modules.
/app/
----------------build.gradle(app)
----------------build
----------------src/main
----------------AndroidManifext.xml
----------------assets(custom)
----------------java
----------------res
\build
\gradle
\gradle\wrapper

Project Layout as in Project explorer

app
manifests
--------AndroidManifext.xml
java
|
--------com
----------------example
------------------------project name (code will be inside here)
assets(custom)
res (resources)
--------drawable
--------layout(layouts here)
--------menu
--------mipmap
--------values
--------xml
Gradle Scripts

Problems panel

The Problems panel in Android Studio is a centralized and shared issue panel for all design tools, such as Compose Preview, Layout Editor, and Layout Validation. To view the tool window, navigate to View > Tool Windows > Problems.

Sample Code

https://developer.android.com/studio/write/sample-code#menus

Preview Layouts

  1. Choose layout to preview from Project explorer
  2. double click.
  3. there are 3 options for viewing layout
    1. code
    2. split
    3. design(default)

Run app in mobile

Reference

Use Tools >> Device Manager.
Choose Physical

In order to run app in mobile, you should

  1. Enable developer options in mobile.
    To do that go to settings, click build no 7 times. Developer options menu item will appear
    in redmi note 5, its under Settings >> Additional Settings >> Developer options. For other phones find it via google
  2. Pair the phone with Android Studio by pluging the USB code with the phone
    PS : for Android 11+, it can also be paired via Wifi or OTP
  3. Once connected and PC acknowledges it(some cable doesnt work), go to Developer options , Enable USB Debugging (in some phones/ emulators like bluestacks it is Android Debugging & ADB(Android Debugging Bridge) over network).
  4. Ensure device appear in the list(Physical)

PS: For Windows OS ,you might need to install a USB driver for ADB (if applicable). For an installation guide and links to OEM drivers, see Install OEM USB drivers.

Run app in Virtual Device

Reference

Choose Virtual in device manage window

Requirements

  • 16 GB RAM
  • 64-bit Windows, macOS, Linux, or Chrome OS operating system
  • 16 GB disk space

Create a new device

  1. Choose phone type and hit Next
  2. Choose Android version, download System Image clicking down arrow, and hit Next
  3. Set AVD Name, hit Finish
  4. Choose the virtual device created
  5. Ensure device appear in the list(Virtual)

Using Bluestacks Emulator

download

instructions 3.30 on wards

You could detect in chrome with chrome://inspect/devices#devices

And can use Web view for debugging

Development Workflow

Refernce