DEV Community

Cover image for 5 Things I Wish I Knew Before Writing My First Android App
Aalaa Fahiem
Aalaa Fahiem

Posted on

5 Things I Wish I Knew Before Writing My First Android App

This article is for beginners building their first Android app using Kotlin and Jetpack Compose.

So I decided to build an Android app. How hard could it be, right?

Turns out — pretty hard. Not impossible, but full of surprises that nobody warns you about. I'm still learning, but I've already collected a solid list of "why didn't anyone tell me this?" moments. Here are the five biggest ones.


1. Architecture Isn't Just for Big Projects

When I started, I threw everything into one file. Logic, UI, data fetching — all living together in one giant MainActivity.kt. It worked… until it didn't.

The moment I needed to change something, I'd break something else. I had no idea what MVVM (Model-View-ViewModel) was, and honestly the name scared me off.

Here's what I wish someone had told me earlier:

Architecture isn't about being fancy. It's about not hating your own code two weeks later.

Even for a small app, separating your UI (the View) from your logic (the ViewModel) makes everything easier to read, test, and fix. Start with MVVM from day one. Android Jetpack's ViewModel and StateFlow are built for this — don't ignore them.

Takeaway: Before writing a single line of UI code, ask yourself: where will the logic for this live?


2. Android Will Destroy and Recreate Your Activity — Deal With It

This one got me bad.

I had a form where users filled in their details. When I rotated the phone, everything disappeared. I panicked. I thought I had a bug. I didn't — that's just Android doing its thing.

Android destroys and recreates your Activity on configuration changes (like rotation, language change, or dark mode toggle). If you don't handle this, your app loses all its state every time.

The fix? Use a ViewModel — it survives configuration changes. Or use rememberSaveable if you're on Jetpack Compose. Either way, don't store important state directly in your Activity or Fragment and expect it to stick around.

@Composable
fun ExampleScreen(viewModel: MyViewModel = viewModel()) {
    val state by viewModel.uiState.collectAsState()

    Text(text = state.username)
}
Enter fullscreen mode Exit fullscreen mode

Also: permissions. Don't assume the user has granted them. Don't assume they'll stay granted. Always check before you use a camera, location, or microphone — every single time.

Takeaway: The Android lifecycle is not your enemy, but it will punish you if you ignore it.


3. Android Studio and Gradle Will Humble You

I expected a smooth coding experience. What I got instead was:

  • Gradle syncing for 4 minutes
  • Mysterious build errors with no helpful message
  • "Invalidate Caches and Restart" becoming my most-used button

Android Studio is powerful, but it's heavy. Here's what actually helped me:

  • Keep Gradle and your dependencies updated, but not blindly — always check the changelog before upgrading.
  • Learn the difference between implementation, api, and testImplementation in your build.gradle. It matters.
  • When something breaks and you don't know why: clean the project (Build → Clean Project), then rebuild. Fixes more than it should.
  • The Logcat panel is your best friend. Filter by your app's package name and read the errors carefully — they're usually telling you exactly what's wrong.

Takeaway: Gradle is not magic. Learn the basics of how it works and you'll save yourself hours of frustration.


4. AI Agents Are Powerful — But They Can Quietly Mislead You

When I got stuck, I started asking AI assistants (like ChatGPT or Claude) for help. And honestly? They're incredible. They explain errors in plain English, suggest fixes instantly, and can write boilerplate code in seconds.

But there's a trap I fell into: trusting AI output without questioning it.

AI agents don't always know the latest Android APIs. They can confidently suggest a method that was deprecated two versions ago, or generate code that compiles fine but behaves incorrectly at runtime. The code looks right — that's what makes it dangerous for beginners.

Here's how I learned to use AI tools better:

  • Always ask it to explain the code, not just give it to you. If it can't explain a line clearly, that's a red flag.
  • Cross-check with the official Android docs. AI is a great starting point, not the final word.
  • Tell it your context — your API level, whether you're using Compose or XML, Kotlin or Java. Vague questions get vague answers.
  • If something feels off about the generated code, trust that feeling and dig deeper.

AI is like a very fast, very confident pair programmer who sometimes hallucinates. Use it, but stay in the driver's seat.

Takeaway: AI agents can save you hours — but only if you understand what they're giving you.


5. Performance Problems Are Invisible Until They're Not

My first app felt fine on my phone. Then I tested it on an older device and it was sluggish. Scrolling lists stuttered. The UI froze when loading data.

Two things caused most of my problems:

. Doing heavy work on the main thread. Network calls, database reads, file operations — none of these belong on the UI thread. Use coroutines (viewModelScope.launch { })
to move work to the background. It's easier than it sounds.

You don't need to be a performance expert from day one. But knowing that these issues exist means you can avoid the worst of them early.

Takeaway: Run your app on a low-end device or emulator occasionally. It'll reveal problems your flagship phone hides.


Android development has a steep learning curve, and that's okay. Every confusing error message, every configuration change crash, every Gradle failure — it's all part of learning how the platform works.

If you're just starting out: focus on fundamentals, not features.

Build small. Break things. Learn why they broke.

That’s how you actually improve.

Still learning. Still building. Let me know in the comments if any of these hit close to home — or if there's something you wish you'd known sooner!

``
Enter fullscreen mode Exit fullscreen mode

Top comments (0)