Expo-go立即崩溃,没有错误消息(React Native)



问题:

嘿,Stackoverflow。由于互联网问题,我上周只在网络模拟器中测试了我的react原生应用程序。现在我想在世博会上试试,移动模拟器。但是,当我连接到项目并完全构建js时,整个应用程序就会崩溃,而不会出现错误消息。

我试图修复的内容:

现在,我将手机连接到我的windows pc,并运行以下logcat命令:adb logcat *:S ReactNative:V ReactNativeJS:V以这种方式获取错误消息。但我搞不清楚问题出在哪里。

当我运行应用程序时,logcat命令会记录这一点:

10-19 13:54:39.731  9429 11453 I ReactNativeJS: Running "main" with {"initialProps":{"exp":{}},"rootTag":1}
10-19 13:54:39.801  9429 11453 W ReactNativeJS: Constants.installationId has been deprecated in favor of generating and storing your own ID. Implement it using expo-application's androidId on Android and a storage API such as expo-secure-store on iOS and localStorage on the web. This API will be removed in SDK 44.
10-19 13:54:46.209  9429 11682 I ReactNativeJS: Running "main" with {"initialProps":{"exp":{"initialUri":"exp://192.168.1.111:19000","shell":false,"manifestString":"{"name":"productivity","slug":"productivity","version":"1.0.0","orientation":"portrait","icon":".\/assets\/icon.png","splash":{"image":".\/assets\/splash.png","resizeMode":"contain","backgroundColor":"#ffffff","imageUrl":"http:\/\/192.168.1.111:19000\/assets\/.\/assets\/splash.png"},"updates":{"fallbackToCacheTimeout":0},"assetBundlePatterns":["**\/*"],"ios":{"supportsTablet":true},"android":{"adaptiveIcon":{"foregroundImage":".\/assets\/adaptive-icon.png","backgroundColor":"#FFFFFF","foregroundImageUrl":"http:\/\/192.168.1.111:19000\/assets\/.\/assets\/adaptive-icon.png"}},"web":{"favicon":".\/assets\/favicon.png"},"_internal":{"isDebug":false,"projectRoot":"D:\\coding\\apps\\productivity","dynamicConfigPath":null,"staticConfigPath":"D:\\coding\\apps\\productivity\\app.json","packageJsonPath":"D:\\coding\\apps\\productivity\\package.json"},"sdkVersion":"42.0.0","platforms":["ios","android","web"],"developer":{"tool":"expo-cli","projectRoot":"D:\\coding\\apps\\productivity"},"packagerOpts":{"scheme":null,"hostType":"lan","lanType":"ip","devClient":false,"dev":true,"minify":false,"urlRandomness":"2s-g42","https":false},"mainModuleName":"node_modules\\expo\\AppEntry","__flipperHack":"React Native packager is running","debuggerHost":"192.168.1.111:19000","logUrl":"http:\/\/192.168.1.111:19000\/logs","hostUri":"192.168.1.111:19000","bundleUrl":"http:\/\/192.168.1.111:19000\/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false","iconUrl":"http:\/\/192.168.1.111:19000\/assets\/.\/assets\/icon.png","id":"UNVERIFIED-192.168.1.111-productivity","isVerified":true,"primaryColor":"#023C69"}"}},"rootTag":1}

如果这很重要的话,这些是我的版本:

"dependencies": {
"@babel/preset-env": "^7.15.8",
"@react-native-async-storage/async-storage": "^1.15.9",
"@react-native-community/datetimepicker": "^3.5.2",
"@react-native-community/masked-view": "^0.1.11",
"async-storage": "^0.1.0",
"date-fns": "^2.25.0",
"expo": "^42.0.4",
"expo-status-bar": "~1.0.4",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz",
"react-native-color-palette": "^2.2.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "^1.13.1",
"react-native-screens": "^3.8.0",
"react-native-svg": "^12.1.1",
"react-native-vector-icons": "^8.1.0",
"react-native-web": "~0.13.12",
"react-navigation": "^4.4.4",
"react-navigation-drawer": "^2.7.1",
"react-navigation-stack": "^2.10.4"
},

我希望你能帮助我。请随意留言,我也可以运行另一个logcat命令。

在我的例子中。我错误地键入了";fontStyle"而不是";fontSize";。它在ios中很好,但在android中连续崩溃而没有显示任何错误。

我也遇到了同样的问题,这让我抓狂。在我的项目目录中,我运行了:

npm安装-g expo-clinpx-expo-cli升级

我得到了";您当前使用的是SDK 47.0.0。是否要更新到最新版本48.0.0"回答是的。

更新后,它工作了!

我不确定这是否有帮助,但我在Expo Go中也遇到了稳定性问题。它们的范围从我试图运行Snack的React Native项目时突然崩溃到无法通过启动屏幕。我早些时候在Google Play上查看了Expo Go的评论,发现有几个人报告了多个稳定性问题。虽然通过Snack在线预览运行RN很方便,但我认为我可能需要通过设备的CLI进行测试。我希望这些问题能尽快得到解决。

在我的例子中,我有一个组件在第一个条件返回之后使用了useState钩子:

function Component() {
// code
if (condition) {
return <LoadingScreen />
}
... //code
const [value, setValue] = useState() // this was causing an error
return <View>
... // code
</View>
}

当我将useState移动到函数顶部时,在第一次返回之前,应用程序停止了崩溃

这已经有一段时间了,但在我的情况下,我使用flex:"33%"作为一种样式。根据经验,如果您使用的CSS属性仅受webexpo支持,那么go似乎会崩溃,而不会出现错误消息。

在我的情况下,这是因为我键入了:

paddingTop: "200px"

而不是:

paddingTop: 200

希望能有所帮助。

在我的情况下(android立即崩溃),它是文件android/app/src/main/res/xml/network_security_config.xml中的一个重复条目。

我通过打开android工作室中的android-文件夹并从那里运行应用程序找到了它。在Logcat选项卡中,我看到以下错误:

2023-04-04 12:12:16.096 13209-13209/com.evolute E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myappname, PID: 13209
java.lang.RuntimeException: Unable to instantiate application com.myappname.MainApplication package com.myappname: java.lang.RuntimeException: Failed to parse XML configuration from network_security_config

在堆叠跑道的另一边,我注意到了这条线:

Caused by: android.security.net.config.XmlConfigSource$ParserException: 127.0.0.1 has already been specified at: Binary XML file line #11

删除重复项为我解决了这个问题。

如果有人像我一样不知所措,我发现出于某种原因,Android不喜欢在构建中存储一些x大小的图像。在使用Expo Go时,没有任何日志显示这一点,但使用adb logcat时,它显示位图过大存在错误,我认为这与我在逐个文件重建整个应用程序以最终找到罪魁祸首后找到的解决方案有关。

希望这能帮助到别人!

相关内容

  • 没有找到相关文章

最新更新