ReactNative:Error: Activity class {.MainActivity} does not exist.

Published on:
Last updated:

This post is also available in: 日本語 (Japanese)

When developing an Android smartphone application with ReactNative, an error occurred when debugging the actual machine, and the application screen quit when it was launched.
The following is that error messages filtered by app name by using AVD Manager of Android SDK Tools.
The part of com.sampleproject contains application ID specified by developer.

Starting: Intent { cmp=com.sampleproject/.MainActivity }
Error type 3
Error: Activity class {com.sampleproject/com.sampleproject.MainActivity} does not exist.

In my case, the cause of the error is that Application ID(first two files) and package name(the remaining two files) in the following files in the ReactNative project folder are not unified. It seemed to be the cause.

YourProjectFolder/Settings.gradle
YourProjectFolder/app/ build.gradle
YourProjectFolder/android/app/src/main/java/com/YourProjectName/MainApplication.java
YourProjectFolder/android/app/src/main/java/com/YourProjectName/MainApplication.java

Reference:
https://github.com/facebook/react-native/issues/14952

No tags for this post.

About
Kuniyoshi Takemoto is the founder of Amelt.net LLC, and editor of this blog(www.amelt.net).Learn more and follow me on LinkedIn.