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

相关推荐
Estar.Lee3 小时前
查手机号归属地免费API接口教程
android·网络·后端·网络协议·tcp/ip·oneapi
温辉_xh3 小时前
uiautomator案例
android
工业甲酰苯胺5 小时前
MySQL 主从复制之多线程复制
android·mysql·adb
少说多做3435 小时前
Android 不同情况下使用 runOnUiThread
android·java
Estar.Lee6 小时前
时间操作[计算时间差]免费API接口教程
android·网络·后端·网络协议·tcp/ip
找藉口是失败者的习惯7 小时前
从传统到未来:Android XML布局 与 Jetpack Compose的全面对比
android·xml
Jinkey8 小时前
FlutterBasic - GetBuilder、Obx、GetX<Controller>、GetxController 有啥区别
android·flutter·ios
大白要努力!10 小时前
Android opencv使用Core.hconcat 进行图像拼接
android·opencv
天空中的野鸟11 小时前
Android音频采集
android·音视频
小白也想学C12 小时前
Android 功耗分析(底层篇)
android·功耗