The complete guide to Android development with Kotlin
π€ Android Complete Guide
From the moment you first open Android Studio to the moment you publish to the Play Store, this guide walks through the whole process of building an Android app with Kotlin and Jetpack Compose, one step at a time. It is organized so you understand the reasons behind each step as well.
Intermediate
Updated Oct 1, 2026
~13 min read
19 sections
14 code examples
π€
Mobile app developmentJetpack Compose UINetworking with RetrofitMVVM architecturePublishing to the Play Store
From the moment you first open Android Studio to the moment you publish to the Play Store, this guide walks through the whole process of building an Android app with Kotlin and Jetpack Compose, one step at a time. It is organized so you understand the reasons behind each step as well. Rather than listing concepts, this guide is organized so you can follow the content in the order you have to make decisions on a real project.
Key perspective
Frontend / app development
Do not stop at drawing the screen: look at state, data requests, routing, accessibility, and the unit of deployment together.
Mobile app developmentJetpack Compose UINetworking with RetrofitMVVM architecturePublishing to the Play Store
Architecture diagrams
To make what you read stick, it helps to capture the flow as a picture first. The two diagrams below are reference maps you can keep coming back to while learning Android.
Learning flow
Rendering diagramβ¦
Architecture view
Rendering diagramβ¦
What is Android development?
When you first open Android, the big picture matters more than individual commands. This section starts with the problems the concepts ahead were created to solve.
Android is the mobile operating system from Google that runs on more than 70% of the smartphones in the world. The first thing newcomers wonder is "which language and tools should I start with?", and the short answer is that the Kotlin language + the Jetpack Compose UI toolkit is the modern standard Google has officially recommended since 2024. Java + XML layouts used to be the standard, but if you are learning now there is no need to pick up the old way first. This guide uses only Kotlin and Compose from start to finish.
Compose may feel unfamiliar, but put simply it means declaring "what to draw on screen and how" directly as Kotlin functions instead of XML files. If you have worked with React or Flutter, the idea that "the screen redraws automatically when state changes" is exactly the same, so you will get used to it quickly. There is no need to worry if this is your first time β this guide explains each concept alongside real code.
Aspect
The old way
The way this guide covers
Writing UI
XML layout files
Kotlin @Composable functions
Language
Java
Kotlin (more concise and null safe)
Reflecting state
Manual updates through findViewById
Automatic recomposition when state changes
Officially recommended
In maintenance mode
The current official Google standard (2024 onward)
Setting up the environment
Here you look at Setting up the environment alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.
Android development needs exactly one thing: Android Studio, the official IDE. It includes the code editor, the Android SDK (the set of tools needed to build), and the emulator (a virtual smartphone), so there is no need to install several separate programs.
BASH
# The first time you launch Android Studio after installing, the "Setup Wizard" appears.# Choose the Standard option and the Android SDK, build tools, and emulator image# are downloaded automatically. (About 10-20 minutes depending on your connection)# To confirm the install finished, go to the top menu:# Android Studio > Settings > Languages & Frameworks > Android SDK# and check that the latest SDK Platform (API 34 or higher) is ticked.
Operating system
How to install
Notes
Windows
Download the .exe installer from the official site and run it
Keep the "Android Virtual Device" item checked during installation
macOS
Download the .dmg from the official site (check Apple Silicon vs Intel)
On an M1/M2/M3 chip, be sure to download the Apple Silicon build
Linux
Extract the .tar.gz from the official site and run studio.sh
A 64-bit distribution is recommended; KVM virtualization must be enabled
Creating your first project
Here you look at Creating your first project alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.
Launch Android Studio and choose New Project on the welcome screen. Picking Empty Activity from the template list starts you with just the minimal structure you need and no unnecessary sample code. (In recent versions of Android Studio that support Compose, Empty Activity is generated on Compose automatically.)
BASH
# When the project has been created, press the green βΆ (Run) button in the top toolbar.# If no real device is connected, Android Studio starts the emulator automatically# and a moment later you see your first app showing "Hello Android!" on screen.# If the emulator list is empty:# click the Device Manager icon on the right β Create Device β choose Pixel 8# β download a system image (API 34 or similar) β Finish
Setting
Meaning
Recommended for beginners
Name
The app name (the name people see)
Anything you like (e.g. MyFirstApp)
Package name
The globally unique identifier of the app
Reverse-domain form such as com.example.myfirstapp
Save location
The folder where the project files are stored
Keep the default
Language
The programming language to use
Kotlin (default)
Minimum SDK
The oldest Android version the app will support
API 24 (Android 7.0) β a baseline widely used in practice
Understanding the project structure
Understanding the project structure is a point where the options diverge. Using the table to compare what each approach is for and how it differs in operation makes later decisions much easier.
When you first open a project, the file tree on the left is full of unfamiliar folders, which can be daunting. But the files you actually touch every day are a fixed few. Remembering just the ones in the table below is enough.
Path
What is it?
When do you open it?
app/src/main/java/.../MainActivity.kt
The entry point code called when the app first starts
Almost always β this is where you wire in your Composables
app/src/main/res/
Resources such as images, icons, strings, and colors
When changing images or the app name
app/src/main/AndroidManifest.xml
The configuration file that declares the app name, permissions, and list of screens
When a permission such as the camera is needed
app/build.gradle.kts
The libraries (dependencies) and build settings for this app module
When adding a new library β the file you open most often
build.gradle.kts (project root)
Common build settings applied to the whole project
Almost never
First steps with Compose: Composable functions
Here you look at First steps with Compose: Composable functions alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.
In Compose, every piece of the screen is built as an ordinary Kotlin function annotated with @Composable. It is not special syntax, just a function, so you can call other Composables to combine them and take parameters to reuse them.
Looking at the example below line by line: Column is a layout that stacks its children vertically, Text displays text, and Button is a button that can be pressed. Calling the Composable we wrote inside the setContent { } block of MainActivity draws it on screen.
MainActivity.ktKOTLIN
import android.os.Bundleimport androidx.activity.ComponentActivityimport androidx.activity.compose.setContentimport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.paddingimport androidx.compose.material3.Buttonimport androidx.compose.material3.Textimport androidx.compose.runtime.Composableimport androidx.compose.ui.Modifierimport androidx.compose.ui.unit.dp// @Composable: marks "this function draws UI"@Composablefun Greeting(name: String) { Column(modifier = Modifier.padding(16.dp)) { Text(text = "Hello, $name!") Button(onClick = { /* code to run when the button is pressed */ }) { Text("Press me") } }}class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // Calling a Composable inside setContent draws it on screen setContent { Greeting(name = "AI DevOps") } }}
Layout & Modifier
Here you look at Layout & Modifier alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.
Most Compose layout is handled by three basic containers. Column arranges its children vertically, Row horizontally, and Box stacks its children on top of each other. The idea is similar to flexbox in HTML/CSS.
A Modifier is the tool for attaching extra properties such as size, padding, alignment, and click handling by chaining calls. The important point is that the order in which Modifiers are written affects the result. For example, applying padding first and then the click area behaves differently from setting the click area first and then the padding. It is fine not to worry about the order at first, but if a layout comes out differently from what you expected, suspect the Modifier order.
KOTLIN
@Composablefun ProfileCard() { Row( modifier = Modifier .fillMaxWidth() // fill the full width of the screen .padding(16.dp), // 16dp of outer padding verticalAlignment = Alignment.CenterVertically ) { Column { Text("Jane Doe") Text("Android developer") } Spacer(modifier = Modifier.weight(1f)) // takes all the remaining space (pushes the next item to the right) Text("Follow") }}
State management: remember and mutableStateOf
Here you look at State management: remember and mutableStateOf alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.
The core principle of Compose is that "when State changes, the UI that reads that state is redrawn automatically". This is called recomposition.
remember "remembers" a value so it is not lost when the Composable function runs again (recomposition), and mutableStateOf is an observable state holder that tells Compose "redraw the UI that reads this value" when the value changes. If you do not use the two together (for example, declaring just var count = 0), the value changes but the screen is not updated β the mistake first-time learners make most often.
KOTLIN
@Composablefun Counter() { // remember: keeps the value across recompositions // mutableStateOf: when the value changes, the UI reading it is redrawn automatically // with the by keyword you read and write count directly instead of count.value var count by remember { mutableStateOf(0) } Column { Text(text = "Count: ${count}") Button(onClick = { count++ }) { Text("Increment") } }}
List UI: LazyColumn
Here you look at List UI: LazyColumn alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.
Most app screens list many items, such as a list of posts or chats. Laying the items out one by one in an ordinary Column draws all of them at once when there are 100 or 1,000, and performance drops sharply.
LazyColumn behaves "lazily", as the name says: it draws only the items actually visible on screen and adds just what is needed as you scroll. It is the same idea as virtual scrolling in web development.
KOTLIN
data class Todo(val id: Int, val title: String)@Composablefun TodoList(todos: List<Todo>) { LazyColumn { items(todos, key = { it.id }) { todo -> Text( text = todo.title, modifier = Modifier.padding(12.dp) ) } }}
Navigating between screens (Navigation Compose)
Here you look at Navigating between screens (Navigation Compose) alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.
With two or more screens, an app needs a way to move between them. The Navigation Compose library works by registering the navigable screens under "route" names and navigating by calling those names from code. If you have worked with URL routing in web development, the concept is very familiar.
KOTLIN
@Composablefun AppNavHost() { val navController = rememberNavController() NavHost(navController = navController, startDestination = "home") { composable("home") { HomeScreen(onNavigateToDetail = { navController.navigate("detail") // go to the "detail" screen }) } composable("detail") { DetailScreen(onBack = { navController.popBackStack() // return to the previous screen }) } }}
ViewModel and the lifecycle
Here you look at ViewModel and the lifecycle alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.
When the screen is rotated, Android by default recreates the whole Activity. All state stored with remember is lost at that point. It would be very annoying for the text a user was typing or the data that was loaded to vanish on a single rotation.
A ViewModel is a separate class that survives this kind of screen recreation. The screen (the Composable) only subscribes to the state the ViewModel holds, and all the logic that creates and changes the actual data lives inside the ViewModel. Dividing the roles this way cleanly separates UI code from business logic and makes testing much easier (this is called the MVVM architecture).
KOTLIN
class CounterViewModel : ViewModel() { // private set: readable from outside, modifiable only inside this class var count by mutableStateOf(0) private set fun increment() { count++ }}@Composablefun CounterScreen(viewModel: CounterViewModel = viewModel()) { Column { Text("Count: ${viewModel.count}") Button(onClick = { viewModel.increment() }) { Text("Increment") } }}
Networking (Retrofit + coroutines)
Here you look at Networking (Retrofit + coroutines) alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.
For REST API calls that fetch data from a server, the combination of the Retrofit library and Kotlin coroutines is the working standard. Putting the suspend keyword in front of a function means "this function may take time, and it will not block other work (such as drawing the screen) while it waits" β you can write it in order like synchronous code, with no callback hell.
KOTLIN
data class User(val id: Int, val name: String)interface ApiService { @GET("users") suspend fun getUsers(): List<User>}val api: ApiService = Retrofit.Builder() .baseUrl("https://api.example.com/") .addConverterFactory(GsonConverterFactory.create()) .build() .create(ApiService::class.java)class UserViewModel : ViewModel() { var users by mutableStateOf<List<User>>(emptyList()) private set fun loadUsers() { // viewModelScope: the coroutine is cancelled automatically when the ViewModel goes away viewModelScope.launch { try { users = api.getUsers() } catch (e: Exception) { // handle network errors, server errors, and so on here } } }}
Handling permissions
Here you look at Handling permissions alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.
Accessing sensitive user information such as the camera, location, or storage takes two steps. First, declare which permissions are needed in AndroidManifest.xml. Second, while the app is running, actually ask the user for the permission and get approval (Android 6.0 and later use "runtime permissions", which ask at the moment of use rather than at install time).
@Composablefun CameraScreen() { val context = LocalContext.current val launcher = rememberLauncherForActivityResult( ActivityResultContracts.RequestPermission() ) { granted -> if (granted) { // handle the case where the permission was granted } else { // denied β it is good to show guidance UI that explains why } } Button(onClick = { launcher.launch(Manifest.permission.CAMERA) }) { Text("Request camera permission") }}
Local data storage (DataStore)
Here you look at Local data storage (DataStore) alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.
Simple settings that must survive closing and reopening the app (for example dark mode, or whether to stay signed in) are stored in DataStore. SharedPreferences used to be used for this, but DataStore is coroutine-based, so it does not block the UI thread, and the data can be observed as a Flow, which is why DataStore is recommended for modern projects. For complex data spanning several tables, use Room, a separate local database library.
KOTLIN
val Context.dataStore by preferencesDataStore(name = "settings")val DARK_MODE_KEY = booleanPreferencesKey("dark_mode")// Savesuspend fun setDarkMode(context: Context, enabled: Boolean) { context.dataStore.edit { prefs -> prefs[DARK_MODE_KEY] = enabled }}// Observe the value as a Flow β a new value arrives automatically whenever it changesfun darkModeFlow(context: Context): Flow<Boolean> = context.dataStore.data.map { prefs -> prefs[DARK_MODE_KEY] ?: false }
Writing tests
Here you look at Writing tests alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.
"How do I test UI?" is a part many beginners skip, but Compose makes UI testing fairly easy. You bring up a test screen with createComposeRule(), find text or a button, click it, and check the result. Logic that is separate from the UI, such as a ViewModel, can be verified much faster with plain Kotlin unit tests.
KOTLIN
class CounterTest { @get:Rule val composeTestRule = createComposeRule() @Test fun clickingButton_incrementsCounter() { composeTestRule.setContent { Counter() } // check the initial state composeTestRule.onNodeWithText("Count: 0").assertExists() // click the button composeTestRule.onNodeWithText("Increment").performClick() // check the state after the click composeTestRule.onNodeWithText("Count: 1").assertExists() }}
Build and release
Here you look at Build and release alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.
Once testing is done, it is time to ship the app to real users. An unsigned debug APK is enough during development, but publishing to the Play Store requires an AAB (Android App Bundle) file with a digital signature. Signing is the procedure that proves "this app really was built by me (the developer)".
BASH
# Build a debug APK for testing during development./gradlew assembleDebug# Build the release App Bundle for submission to the Play Store./gradlew bundleRelease
Step
What to do
1. Create a signing key
Create a keystore file with the Build β Generate Signed Bundle/APK wizard in Android Studio and keep it safe (if you lose it, you cannot update the same app)
2. Release build
Build an AAB file signed with that keystore
3. Register in the Play Console
Register as a developer in the Google Play Console (a one-time registration fee applies) and upload the AAB
4. Staged rollout
Rolling out in stages β internal testing β closed testing β full release β is the safe way
Android practical design
Android practical design is a point where the options diverge. Using the table to compare what each approach is for and how it differs in operation makes later decisions much easier.
On Android, separate the Compose UI from the business logic at the ViewModel boundary. A structure in which State is managed as a single source of truth and the UI only subscribes to that state is better for maintainability.
Decision point
Question to ask
Practical guideline
Boundaries
Which parts of the Android code are most likely to change?
Separate input/output, configuration, external integrations, and the core rules.
State
Where is state created and where does it go away?
Make the owner and lifecycle of state visible in the code.
Failure
What does the caller receive on failure?
Decide the timeout, fallback, and error contract first.
Android operating standards
This section covers Android operating standards from a practical perspective. Instead of memorizing the concept, focus on the situations in which you would reach for it.
The essentials in operation are coroutine scopes matched to the Lifecycle (viewModelScope), preventing memory leaks, background work (WorkManager), and APK/AAB size management.
Android verification strategy
Android verification strategy is a point where the options diverge. Using the table to compare what each approach is for and how it differs in operation makes later decisions much easier.
With Compose, separate UI tests (ComposeTestRule) from ViewModel unit tests, and include screen rotation and process recreation scenarios in the regression tests.
Quality axis
How to verify
Definition of done
Correctness
Automate the normal/failure cases.
The core scenarios pass reproducibly.
Regression prevention
When fixing a bug, leave the same case behind as a test.
The same failure is not deployed again.
Operability
Check the logs, metrics, and alerts.
There is a path for tracing the cause when a problem occurs.
Android: frequently asked questions
Should I learn Jetpack Compose or XML layouts?
If you are starting now, learn Jetpack Compose first. It is the UI toolkit Google recommends, and you write screens declaratively in Kotlin code. Existing apps still contain plenty of XML layouts, so in practice it helps to know them well enough to read and modify.
Why does entered text disappear when I rotate the screen?
A configuration change such as rotation destroys the Activity and creates it again. Screen state kept in a ViewModel survives configuration changes, and values that must be restored even after the process is killed use saved state.
When do I use an Activity and when a Fragment?
An Activity is a screen unit that serves as an entry point to the app, and a Fragment is a piece of UI that can be swapped or combined inside an Activity. A single Activity holding several screens switched by navigation is now the common structure, and with Compose screens are built from composable functions.
Next steps
This section covers Next steps from a practical perspective. Instead of memorizing the concept, focus on the situations in which you would reach for it.
If you have come this far, you have all the fundamentals for building and releasing an Android app from start to finish. Next, it is worth digging into Hilt (a cleaner code structure through dependency injection), Room (complex local databases), StateFlow (finer-grained ViewModel state management), and the Material 3 design system. Whenever you get stuck, come back to the sections of this guide to review.