解決VSCode調(diào)試react-native android項(xiàng)目錯(cuò)誤問題
如果運(yùn)行react-native android項(xiàng)目出現(xiàn)如下錯(cuò)誤:

解決辦法如下:
一、執(zhí)行adb devices,判斷adb有沒有斷,
二、如果是adb斷了就使用一下步驟
adb reverse tcp:8081 tcp:8081 npm start
如果adb沒斷,直接
npm start
如果執(zhí)行g(shù)radle ass打包命令進(jìn)行打包之后,出現(xiàn)如下錯(cuò)誤:

1、檢查react-native項(xiàng)目工程目錄下的index.js里面的AppRegistry.registerComponent(appName, () => App);看注冊的項(xiàng)目名是什么,這個(gè)注冊的項(xiàng)目名很重要;
2、檢查android工程下的MainActivity的以下方法返回的是什么:
@Override protected String getMainComponentName() { return 'whzsagent'; }
3、檢查android工程app/src/main/assets/index.android.bundle文件當(dāng)中r.exports={name:'whzsagent',displayName:'whzsagent'}},APP_ANDROID_UPDATE_TYPE:’whzsagent-android’,APP_IOS_UPDATE_TYPE:’whzsagent-ios’這4個(gè)地方
4、檢查ios目錄下的AppDelegate.m文件的如下方法:
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation moduleName:@'whzsagent' initialProperties:nil launchOptions:launchOptions];
以上4個(gè)地方返回的值要是統(tǒng)一的,否則打包之后啟動(dòng)app運(yùn)行就會(huì)報(bào)以上錯(cuò)誤。
有時(shí)候修改了ip地址,修改了app的包名,app注冊模塊名等之后,打包apk再運(yùn)行時(shí)會(huì)發(fā)現(xiàn)要么地址總是指向不對,要么就是啟動(dòng)異常,這個(gè)時(shí)候可能就是app/src/main/assets/index.android.bundle文件導(dǎo)致的,必要時(shí)需要重新編譯該文件
app/src/main/assets/index.android.bundle文件的編譯方法為:
第一步:在Android/app/src/main目錄下創(chuàng)建一個(gè)空的assets文件夾第二步:react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
到此這篇關(guān)于VSCode調(diào)試react-native android項(xiàng)目錯(cuò)誤解決辦法的文章就介紹到這了,更多相關(guān)VSCode調(diào)試react-native android報(bào)錯(cuò)內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. CentOS郵箱服務(wù)器搭建系列——SMTP服務(wù)器的構(gòu)建( Postfix )2. asp文件用什么軟件編輯3. PHP基礎(chǔ)之生成器4——比較生成器和迭代器對象4. ASP新手必備的基礎(chǔ)知識(shí)5. Docker 啟動(dòng)Redis 并設(shè)置密碼的操作6. vue+element開發(fā)一個(gè)谷歌插件的全過程7. Vue axios獲取token臨時(shí)令牌封裝案例8. JS中6個(gè)對象數(shù)組去重的方法9. 利用CSS制作3D動(dòng)畫10. Spring如何替換掉默認(rèn)common-logging.jar

網(wǎng)公網(wǎng)安備