且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 applicationIdSuffix 时 React Native 应用程序不会启动

更新时间:2022-12-21 18:38:58

从上面的链接看,已经在github上讨论了很长时间(一年多),而且好像有几个补丁在路上,所以根据您使用的 react-native 版本,我在下面的修复可能有效也可能无效.

From the link above, it's been discussed for a long time (over a year) on github, and there seems to be a few patches on their way, so my fix below may or may not work depending on the version of react-native you're using.

这是我(暂时)解决问题的方法.问题是 react-native-cli 尝试使用错误的参数调用 adb shell am start:

Here's how I've (temporarily) solved the issue. The problem is that react-native-cli tries to call adb shell am start with the wrong argument:

com.packagename/com.packagename.MainActivity

什么时候应该调用类似

com.packagename.debug/com.packagename.MainActivity

因此,在您的 react-native 版本被修复之前,您可以使用此命令(如 此代码推送 PR:

So until your version of react-native is fixed, you can use this command (as recommended in this code-push PR:

cd android && ./gradlew installDebug && adb -s <DEVICE_ID> shell am start -n com.packageName.debug/com.packageName.MainActivity

这不是一个完美的修复,但是 github 上有一个补丁基本上做同样的事情(关于几个问题和拉取请求这里 & 这里).

It's not a perfect fix, but there's a patch on github which does essentially the same thing (in relation to a couple of issues and pull requests here & here).