Android Studio: Didn't find class "com.example.kotlincoroutines.MainActivity" and similar runtime errors

Viewed 61

I know that these types of errors are common in Android Studio. The error occurred because of not entering the path ".main.MainActivity" where the MainActivity is located in the manifest. My question is why the framework cannot spot such errors during the compilation? It looks like a silly mistake but after so much hype about compile time error checking these kinds of errors go unnoticed and the app crashes when running.

1 Answers

There is already a way to automate this by going to File >> New >> Activity. By going through this way studio will automate both creation of Java / Kotlin File and addding the entry to Manifest file.

If you instead create a class & then extend Android activity then studio will not automate this behavior because in some more advanced cases users want to do this step on there own thus having a better understanding of how the system is wired.

As to why this is not being done by compile time error checking is because this is not an error like a null pointer exception i.e. logical code error instead this is about how the app is being configured. Configuration errors are never part of compile-time checking.

Related