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

相关推荐
- 羊羊不超越 -4 分钟前
App渠道来源追踪方案全面分析(iOS/Android/鸿蒙)
android·ios·harmonyos
wk灬丨1 小时前
Android Kotlin Flow 冷流 热流
android·kotlin·flow
千雅爸爸1 小时前
Android MVVM demo(使用DataBinding,LiveData,Fresco,RecyclerView,Room,ViewModel 完成)
android
September_ning1 小时前
React.lazy() 懒加载
前端·react.js·前端框架
web行路人1 小时前
React中类组件和函数组件的理解和区别
前端·javascript·react.js·前端框架
番茄小酱0011 小时前
Expo|ReactNative 中实现扫描二维码功能
javascript·react native·react.js
晨曦_子画1 小时前
编程语言之战:AI 之后的 Kotlin 与 Java
android·java·开发语言·人工智能·kotlin
孤客网络科技工作室2 小时前
AJAX 全面教程:从基础到高级
android·ajax·okhttp
Mr Lee_3 小时前
android 配置鼠标右键快捷对apk进行反编译
android
Rattenking3 小时前
React 源码学习01 ---- React.Children.map 的实现与应用
javascript·学习·react.js