首页 > 解决方案 > 当我尝试在 android 模拟器中运行 react native 时。我得到错误类型 3。错误:活动类 {com.eg/com.eg.MainActivity} 不存在

问题描述

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.

标签: javascriptreactjsreact-nativereact-reduxredux-saga

解决方案


如果您将产品风味或变体与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 有望在未来解决这个问题。


推荐阅读