解決VSCode調(diào)試react-native android項(xiàng)目錯(cuò)誤問(wèn)題
如果運(yùn)行react-native android項(xiàng)目出現(xiàn)如下錯(cuò)誤:
解決辦法如下:
一、執(zhí)行adb devices,判斷adb有沒(méi)有斷,
二、如果是adb斷了就使用一下步驟
adb reverse tcp:8081 tcp:8081 npm start
如果adb沒(méi)斷,直接
npm start
如果執(zhí)行g(shù)radle ass打包命令進(jìn)行打包之后,出現(xiàn)如下錯(cuò)誤:
1、檢查react-native項(xiàng)目工程目錄下的index.js里面的AppRegistry.registerComponent(appName, () => App);看注冊(cè)的項(xiàng)目名是什么,這個(gè)注冊(cè)的項(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注冊(cè)模塊名等之后,打包apk再運(yùn)行時(shí)會(huì)發(fā)現(xiàn)要么地址總是指向不對(duì),要么就是啟動(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)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. PHP循環(huán)與分支知識(shí)點(diǎn)梳理2. 利用ajax+php實(shí)現(xiàn)商品價(jià)格計(jì)算3. ThinkPHP5 通過(guò)ajax插入圖片并實(shí)時(shí)顯示(完整代碼)4. JSP之表單提交get和post的區(qū)別詳解及實(shí)例5. SXNA RSS Blog 聚合器程序6. ASP中格式化時(shí)間短日期補(bǔ)0變兩位長(zhǎng)日期的方法7. Ajax請(qǐng)求超時(shí)與網(wǎng)絡(luò)異常處理圖文詳解8. JavaWeb Servlet中url-pattern的使用9. jsp EL表達(dá)式詳解10. .NET6打包部署到Windows Service的全過(guò)程
