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

相关推荐
Java陈序员1 分钟前
再见 Navicat!一款开源的 Web 数据库管理工具!
java·react.js·docker
HarderCoder4 分钟前
ByAI:Rect-redux实现及connect函数
前端·react.js
harry235day13 分钟前
Compose 带动画的待办清单列表页
android·android jetpack
vocal13 分钟前
我的安卓第一课:四大组件之一Activity及其组件RecyclerView
android
咕噜企业签名分发-淼淼39 分钟前
如何实现安卓端与苹果端互通的多种方案
android
wu_android1 小时前
Android 线性布局中常见的冲突属性总结
android
小满zs1 小时前
Zustand 第三章(状态简化)
前端·react.js
恋猫de小郭2 小时前
为什么跨平台框架可以适配鸿蒙,它们的技术原理是什么?
android·前端·flutter
张风捷特烈3 小时前
每日一题 Flutter#5,6 | 两道 Widget 选择题
android·flutter
移动开发者1号3 小时前
App主界面点击与跳转启动方式区别
android·kotlin