I'm building a Quran app using Jetpack Compose in Kotlin. The app builds successfully and installs on a real Android device (Samsung S908E), but crashes instantly on launch.
Crash Log:
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.warattil.quran.ui.components.AllSurahsScreen" on path: ...
But the class does exist:
The file is present under:
app/src/main/java/com/warattil/quran/ui/components/AllSurahsScreen.kt
Here’s the class definition:
package com.warattil.quran.ui.components
@Composable
fun AllSurahsScreen(surahs: List<Surah>) {
// UI Code here...
}
It’s being used like this in MainActivity.kt:
import com.warattil.quran.ui.components.AllSurahsScreen
@Composable
fun MainNavigation(navController: NavHostController, surahs: List<Surah>) {
NavHost(navController = navController, startDestination = "all_surahs") {
composable("all_surahs") {
AllSurahsScreen(surahs = surahs)
}
}
}
Other notes:
- App runs fine on emulator, only crashes on real device
- Using Jetpack Compose + Kotlin 1.9.10
- Build is successful in Android Studio
AndroidManifest.xmlhas the correct package and launcher activity- No ProGuard/R8 obfuscation enabled (for now)
What I’ve tried:
- Cleaned + rebuilt the project
- Invalidated cache / restarted
- Verified the package name and class path
- Ensured no typos in imports or filenames
- Checked logcat for other hints
Question:
Why is the app throwing a ClassNotFoundException for a valid class that compiles and builds fine?
Is there something about Compose navigation or Gradle that might cause this?