March was the month I realized that even after years of CSE, stupid mistakes are still possible. A simple Intent call turned into a 2-day debugging session because of one tiny missing line in a Manifest file.
The Ghost Intent
I was trying to launch a profile activity from the dashboard. Everything looked perfect in the Java/Kotlin code, but the app crashed every single time I clicked the button.
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.avni.app/com.avni.app.ProfileActivity}; have you declared this activity in your AndroidManifest.xml?
The Culprit
Yes, I had declared it. Or so I thought. Because I was using multiple modules, I had declared the activity in the library module's manifest, but forgot to merge it into the main app's manifest correctly.
Wait, it gets worse. I actually had a typo in the package path inside the manifest.
com.avni.app.profileactivity instead of ProfileActivity (case
sensitivity!).
<activity
android:name=".ProfileActivity"
android:exported="false" />
The Golden Rule
When working with Intents, always check your Manifest first. If it's a library module, double-check that the manifest merger is working. And for heaven's sake, double-check your spelling and case sensitivity. Android Studio doesn't always flag manifest package errors at compile time!