久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

解決VSCode調試react-native android項目錯誤問題

瀏覽:4日期:2022-09-21 11:51:59

如果運行react-native android項目出現如下錯誤:

解決VSCode調試react-native android項目錯誤問題

解決辦法如下:

一、執行adb devices,判斷adb有沒有斷,

二、如果是adb斷了就使用一下步驟

adb reverse tcp:8081 tcp:8081 npm start

如果adb沒斷,直接

npm start

如果執行gradle ass打包命令進行打包之后,出現如下錯誤:

解決VSCode調試react-native android項目錯誤問題

1、檢查react-native項目工程目錄下的index.js里面的AppRegistry.registerComponent(appName, () => App);看注冊的項目名是什么,這個注冊的項目名很重要;

2、檢查android工程下的MainActivity的以下方法返回的是什么:

@Override protected String getMainComponentName() { return 'whzsagent'; }

3、檢查android工程app/src/main/assets/index.android.bundle文件當中r.exports={name:'whzsagent',displayName:'whzsagent'}},APP_ANDROID_UPDATE_TYPE:’whzsagent-android’,APP_IOS_UPDATE_TYPE:’whzsagent-ios’這4個地方

4、檢查ios目錄下的AppDelegate.m文件的如下方法:

RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation moduleName:@'whzsagent' initialProperties:nil launchOptions:launchOptions];

以上4個地方返回的值要是統一的,否則打包之后啟動app運行就會報以上錯誤。

有時候修改了ip地址,修改了app的包名,app注冊模塊名等之后,打包apk再運行時會發現要么地址總是指向不對,要么就是啟動異常,這個時候可能就是app/src/main/assets/index.android.bundle文件導致的,必要時需要重新編譯該文件

app/src/main/assets/index.android.bundle文件的編譯方法為:

第一步:在Android/app/src/main目錄下創建一個空的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/

到此這篇關于VSCode調試react-native android項目錯誤解決辦法的文章就介紹到這了,更多相關VSCode調試react-native android報錯內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Android
相關文章:
主站蜘蛛池模板: 宣恩县| 石台县| 合肥市| 贵定县| 洮南市| 增城市| 湘乡市| 凤冈县| 宜章县| 威海市| 宁波市| 香河县| 满城县| 安宁市| 大洼县| 乌苏市| 滁州市| 永仁县| 互助| 平昌县| 五河县| 东兴市| 延安市| 定陶县| 湘乡市| 云阳县| 玛纳斯县| 吐鲁番市| 苏尼特右旗| 宽甸| 石嘴山市| 兴海县| 兰州市| 开平市| 喜德县| 大足县| 南京市| 安新县| 冷水江市| 隆化县| 伊吾县|