android - NSString 类型的 JSON 值无法转换为 ABI38_0_0YGValue
问题描述
几个小时前,我的 expo/React Native 应用程序在本地运行得非常好。但是,为了部署应用程序,我不得不删除整个 node_modules 文件夹并运行 npm install 来恢复它。expo start --ios
从那时起,当我在 IOS 上运行时,我遇到了这个可怕的错误。
出于某种原因,我的应用程序无法再读取“em”样式值。关于会发生什么的任何想法?这是我的配置::
包.json
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"@react-native-community/masked-view": "0.1.10",
"@react-navigation/bottom-tabs": "^5.8.0",
"@react-navigation/compat": "^5.2.5",
"@react-navigation/native": "^5.7.3",
"@react-navigation/stack": "^5.9.0",
"dotenv": "^8.2.0",
"expo": "~38.0.8",
"expo-image-picker": "^8.4.0",
"expo-status-bar": "^1.0.2",
"modal-react-native-web": "^0.2.0",
"moment": "^2.27.0",
"native-base": "^2.13.14",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
"react-native-elements": "^2.3.0",
"react-native-gesture-handler": "^1.3.0",
"react-native-google-books": "^1.0.4",
"react-native-keyboard-aware-scroll-view": "^0.9.2",
"react-native-loading-spinner-overlay": "^1.1.0",
"react-native-screens": "^2.10.1",
"react-native-star-rating": "^1.1.0",
"react-native-web": "~0.11.7"
},
"devDependencies": {
"@babel/core": "^7.8.6",
"babel-preset-expo": "~8.1.0"
},
"private": true
}
应用程序.json
{
"expo": {
"name": "bindersmobile",
"slug": "bindersmobile",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "white"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
解决方案
如果您在 react native 中使用 android 的功能并在 ios 中运行 expo,则会发生该问题。这就是发生在我身上的事情。我设置了样式组件:
const SafeArea = styled(SafeAreaView)`
flex: 1;
margin-top:${StatusBar.currentHeight}
`;
由于“StatusBar.currentHeight”是android功能,我在ios中遇到了这个错误。在 IOS 中“StatusBar.currentHeight”没有返回有效值
我将代码转换为:
const SafeArea = styled(SafeAreaView)`
flex: 1;
${StatusBar.currentHeight && `margin-top:${StatusBar.currentHeight}px`};
`;
此代码告诉,如果“StatusBar.currentHeight”有值,则应用 margin-top。
推荐阅读
- javascript - 特征 '1_1_1_1_1_0' 的属性 'landcover' 缺失
- php - AJAX在Wordpress中返回整个页面
- c# - 连接的列应具有相同的类型(如何将 DateTime 转换或强制转换为正确的类型) ML.NET C# SQL
- c - 如果设置了多个优化标志,clang 会做什么?
- json - 如何将 json 文件导入 mongodb 并选择 _id 字段?
- sql - MariaDB 与 Docker 尝试加载 SQL 文件
- polymer - DY-graph xaxis 范围标记
- twitter - Twitter 流 API,分配的搜索流 API v2 请求
- javascript - 为什么我无法在引导下拉菜单和内部菜单中获得点击事件?
- wordpress - 我们可以使用 rest_prepare 删除 wordpress rest api 中的一些内容吗?