RN(React Native)的应用程序在雷电模拟器可以运行,安卓真机运行失败问题解决记录

yarn react-native build-android打包的apk在真机安卓运行提示:

Unable to load script . Make sure you ' re either running Metro ( run ' npx react - native start ') or that your bundle

' index . android . bundle ' is packaged correctly for release .

jniLoadScriptFromAssets CatalystInstanceImpl . java

loadScriptFromAssets

CatalystInstanceImpl . java :239

loadScript

JSBundleLoader . java :29

runJSBundle

CatalystInstanceImpl . java :268

createReactContext

ReactInstanceManager . java :1413

-$$ Nest $ mcreateReactContext null

run

ReactInstanceManager . java :1111

run

Thread . java :929

DISMISS

( ESC )

RELOAD

( R , R )

主要原因是打包bundle 中出问题,

解决方法:

第一步、在项目目录执行生成bundle

PS E:\ProjectCode\react\Health-Monitoring-System\android> npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output app/src/main/assets/index.android.bundle --assets-dest app/src/main/res

Welcome to Metro v0.73.10

Fast - Scalable - Integrated

info Writing bundle output to:, app/src/main/assets/index.android.bundle

info Done writing bundle output

info Copying 10 asset files

info Done copying assets

第二步、重新打包apk

PS E:\ProjectCode\react\Health-Monitoring-System\android> yarn react-native build-android

yarn run v1.22.19

$ E:\ProjectCode\react\Health-Monitoring-System\node_modules\.bin\react-native build-android

info Starting JS server...

info Building the app...

> Task :app:stripDebugDebugSymbols

Unable to strip the following libraries, packaging them as they are: libc++_shared.so, libcxxcomponents.so, libevent-2.1.so, libevent_core-2.1.so, libevent_extra-2.1.so, libfabricjni.so, libfb.so, libfbjni.so, libflipper.so, libfolly_runtime.so, libglog.so, libglog_init.so, libhermes.so, libhermes_executor.so, libimagepipeline.so, libjsi.so, libjsijniprofiler.so, libjsinspector.so, liblogger.so, libmapbufferjni.so, libnative-filters.so, libnative-imagetranscoder.so, libreact_codegen_rncore.so, libreact_config.so, libreact_debug.so, libreact_nativemodule_core.so, libreact_newarchdefaults.so, libreact_render_animations.so, libreact_render_attributedstring.so, libreact_render_componentregistry.so, libreact_render_core.so, libreact_render_debug.so, libreact_render_graphics.so, libreact_render_imagemanager.so, libreact_render_leakchecker.so, libreact_render_mapbuffer.so, libreact_render_mounting.so, libreact_render_runtimescheduler.so, libreact_render_scheduler.so, libreact_render_telemetry.so, libreact_render_templateprocessor.so, libreact_render_textlayoutmanager.so, libreact_render_uimanager.so, libreact_utils.so, libreactnativeblob.so, libreactnativejni.so, libreactperfloggerjni.so, librrc_image.so, librrc_root.so, librrc_scrollview.so, librrc_text.so, librrc_textinput.so, librrc_unimplementedview.so, librrc_view.so, libruntimeexecutor.so, libturbomodulejsijni.so, libyoga.so.

BUILD SUCCESSFUL in 27s

127 actionable tasks: 33 executed, 94 up-to-date

模拟器使用记录:

adb devices可能看不到雷电模拟器,但可直接connect去使用

PS E:\ProjectCode\react\Health-Monitoring-System\android> yarn android --deviceId=127.0.0.1:5555

yarn run v1.22.19

$ react-native run-android --deviceId=127.0.0.1:5555

info JS server already running.

info Building the app...

> Task :app:createBundleReleaseJsAndAssets

warning: the transform cache was reset.

Welcome to Metro v0.73.10

Fast - Scalable - Integrated

react native安装运行使用中经常出现readtimeout的解决方法:

直接相应链接拷贝到浏览器下载后直接放到对应到目录里再重新运行即可解决

C:\Users\Lenovo\.gradle\caches\modules-2\files-2.1\org.codehaus.groovy

相关推荐
chenbin___2 小时前
react native text 显示 三行 超出部分 中间使用省略号
javascript·react native·react.js
uwvwko11 小时前
BUUCTF——web刷题第一页题解
android·前端·数据库·php·web·ctf
fzxwl11 小时前
隆重推荐(Android 和 iOS)UI 自动化工具—Maestro
android·ui·ios
LittleLoveBoy14 小时前
踩坑:uiautomatorviewer.bat 打不开
android
居然是阿宋14 小时前
Android核心系统服务:AMS、WMS、PMS 与 system_server 进程解析
android
霸王蟹14 小时前
React Fiber 架构深度解析:时间切片与性能优化的核心引擎
前端·笔记·react.js·性能优化·架构·前端框架
TE-茶叶蛋15 小时前
Uniapp、Flutter 和 React Native 全面对比
flutter·react native·uni-app
CGG9217 小时前
【单例模式】
android·java·单例模式
kp0000017 小时前
PHP弱类型安全漏洞解析与防范指南
android·开发语言·安全·web安全·php·漏洞
outstanding木槿21 小时前
react中安装依赖时的问题 【集合】
前端·javascript·react.js·node.js