Getting a hang of Android Studio
Installation
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
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
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
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
- Choose layout to preview from Project explorer
- double click.
- there are 3 options for viewing layout
- code
- split
- design(default)
Run app in mobile
Use Tools >> Device Manager.
Choose Physical
In order to run app in mobile, you should
- Enable developer options in mobile.
To do that go to settings, clickbuild 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 - 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 - Once connected and PC acknowledges it(some cable doesnt work), go to Developer options , Enable
USB Debugging
(in some phones/ emulators like bluestacks it isAndroid Debugging
&ADB(Android Debugging Bridge) over network
). - 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
Choose Virtual
in device manage window
- 16 GB RAM
- 64-bit Windows, macOS, Linux, or Chrome OS operating system
- 16 GB disk space
Create a new device
- Choose phone type and hit
Next
- Choose Android version, download
System Image
clicking down arrow, and hit Next - Set
AVD Name
, hitFinish
- Choose the virtual device created
- Ensure device appear in the list(Virtual)
Using Bluestacks Emulator
instructions 3.30 on wards
You could detect in chrome with chrome://inspect/devices#devices
And can use Web view for debugging
Development Workflow
|
|