1. adb command not found
描述: 想在设备上调试,终端运行命令报错
原因: adb在sdk/platform-tools或者sdktools文件中,没有在shell的配置文件中添加相应的环境变量
方法: 修改环境变量 window 在环境变量path上添加即可,需要关闭所有终端
或者gitBash上修改 vim ~/.bash_profile
添加如下
ANDROID_HOME=/C/Users/... //...为你的adb.exe的路径
PATH=$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH:.
export PATH
一般adb.exe 就在platform-tool 或者 tools 文件夹里
2. React Native WebView has been removed from 'react-native'
描述: webview can't find from 'react-native'
原因: 在最新版本中(中文版一定要看看是什么版本的,很可能过期的)webview 已经从'react-native'移除
3. StackNavigator is not a function
描述: 在使用官方的react-navigation时发现这货
原因: 英文文档没有看全,版本更新后这个函数没了
方法:
yarn add @react-navigation/native
yarn add react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view
yarn add @react-native-community/masked-view
yarn add @react-navigation/stack
import 'react-native-gesture-handler';这家伙要放在文件最开头 : To finalize installation of react-native-gesture-handler, add the following at the top (make sure it's at the top and there's nothing else before it) of your entry file, such as index.js or App.js
我的代码
import 'react-native-gesture-handler';
...
import { NavigationContainer } from '@react-navigation/native';
import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from '@react-navigation/stack';
const Stack = createStackNavigator();
const App = ()=> {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="Home">
<Stack.Screen name="Login" component={LoginScreen} />
<Stack.Screen name="Map" component={MapScreen} options={{ headerShown: false }} />
</Stack.Navigator>
</NavigationContainer>
)
};
官方的这句话注意下: 💡 @react-navigation/stack depends on @react-native-community/masked-view and the other libraries that we installed in Getting started. If you haven't installed those yet, head over to that page and follow the installation instructions.
基本上问题都可以在这个文档中找到解决办法