1、启动应用后,显示:
unable to load script from assets ‘index.android bundle’ ,make sure your bundle is packaged correctly or youu’re runing a packager server
出现这种问题是因为加载不到 index.android.bundle 而这个文件是在 Android -> app -> src -> main -> assets 文件夹下,如果出现这个问题,就是因为该文件夹下没有这个问题。解决就是手动编译下,生成相应的文件
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
注意:这行命令要在项目跟目录下运行
接着就是看 assets 有没有生成两个文件
接着运行 react-native run-android
ok!!!
2、React-Native: Module AppRegistry is not a registered callable module
在 stackoverflow 上查到的解决办法:
cd android
gradlew clean
然后在次运行 react-native run-android 就可以了
gradlew clean:是清除缓存的意思,至于为什么能解决问题,还是不清楚。
3、在github上下载的项目,在本地运行,报错:
You have not accepted the license agreements of the following SDK components
字面理解是需要接受license;那该怎么做呢?
StackOverflow上给的答案是:
1、找到sdk所在文件目录 -- tools -- bin
2、打开 cmd窗口,运行 sdkmanager --licenses命令
3、一直输入 y 同意就是了
在做上述操作之前,可以找到 sdk 目录下 licenses 文件夹只有一个文件 android-sdk-license,打开该文件,只有一行数字,我猜这就是 license
运行命令后:
又多出来几个文件