1、啟動應用后树瞭,顯示:
unable to load script from assets ‘index.android bundle’ ,make sure your bundle is packaged correctly or youu’re runing a packager server
出現(xiàn)這種問題是因為加載不到 index.android.bundle 而這個文件是在 Android -> app -> src -> main -> assets 文件夾下暖呕,如果出現(xiàn)這個問題,就是因為該文件夾下沒有這個問題。解決就是手動編譯下骡澈,生成相應的文件
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
okF彼琛E屎!
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蜗元,打開該文件,只有一行數(shù)字系冗,我猜這就是 license
運行命令后:
又多出來幾個文件