while i try to run react native in android emulator. I get Error type 3. Error: Activity class {com.eg/com.eg.MainActivity} does not exist

while i try to run react native in android emulator. I get Error type 3. Error: Activity class {com.eg/com.eg.MainActivity} does not exist

BUILD SUCCESSFUL in 10s

154 actionable tasks: 2 executed, 152 up-to-date

info Connecting to the development server...

info Starting the app on "emulator-5554"...
Starting: Intent { cmp=com.baqala/.MainActivity }

Error type 3
Error: Activity class {com.baqala/com.baqala.MainActivity} does not exist.

如果您使用具有 applicationIdSuffix "<YOUR SUFFIX>"

的产品口味或变体,您可能会遇到此错误

我的项目有多种构建类型和产品风格,其中每种风格在 app/build.gradle 中指定 applicationIdSuffix。当您 运行 react-native run-android --variant=<VARIANT> 时,它将构建但无法在模拟器上打开。一个解决方案是将 --appIdSuffix '<YOUR SUFFIX>' 添加到您的 运行 命令

例如:

react-native run-android --variant=stagingDebug --appIdSuffix 'staging'

React Native CLI 有望在未来解决这个问题。