本文翻译自:Unable to load script from assets index.android.bundle on windows

I'm trying to run my first React Native project for first time on my device (Android 4.2.2). 我正在尝试在我的设备(Android 4.2.2)上首次运行我的第一个React Native项目。

And I get: 我得到:

unable to load script from assets index.android.bundle 无法从资产index.android.bundle加载脚本

Commands that I used: 我使用的命令:

  1. cd (project directory)
  2. react-native start
  3. react-native run-android

#1楼

参考:https://stackoom.com/question/30UZP/无法从Windows上的资产index-android-bundle加载脚本


#2楼

I've encountered the same issue while following the React Native tutorial (developing on Linux and targeting Android). 在遵循React Native 教程 (在Linux上开发并定位到Android)时,我遇到了相同的问题。

This issue helped me resolve the problem in following steps. 此问题帮助我按照以下步骤解决了该问题。

  1. (in project directory) mkdir android/app/src/main/assets (在项目目录中) mkdir android/app/src/main/assets
  2. 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
  3. react-native run-android

You can automate the above steps by placing them in scripts part of package.json like this: 您可以通过将它们放在package.json scripts部分中来自动执行上述步骤,如下所示:

"android-linux": "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 && react-native run-android"

Then you can just execute npm run android-linux from your command line every time. 然后,您可以每次在命令行中执行npm run android-linux


#3楼

You can follow the instruction mentioned on the official page to fix this issue. 您可以按照官方页面上提到的说明解决此问题。 This issue occur on real device because the JS bundle is located on your development system and the app inside your real device is not aware of it's location. 由于JS捆绑包位于开发系统上,并且实际设备中的应用程序无法识别其位置,因此在实际设备上会发生此问题。


#4楼

OS: Windows 操作系统:Windows

Another way to resolve this problem after trying two methods above 尝试上述两种方法后,解决此问题的另一种方法
(because I installed SDK not in DEFAULT LOCATION like C:\\users\\"user_name"\\appdata\\local\\sdk ) (因为我没有在默认位置安装SDK ,例如C:\\ users \\“ user_name” \\ appdata \\ local \\ sdk

If you noticed that command line announced: "'adb' is not recognized as an internal or external command..." 如果您注意到命令行宣布:“'adb'不被识别为内部或外部命令...”

So this is how I get over: 所以这就是我克服的方式:
Examples: I installed SDK in D:\\Android\\sdk 示例:我在D:\\ Android \\ sdk中安装了SDK
So I will insert path in System Variables 2 more lines: 因此,我将在“系统变量”的另外2行中插入路径:

D:\Android\sdk\tools
D:\Android\sdk\platform-tools

(If you don't know how to edit path System Variables, here's the topic: https://android.stackexchange.com/questions/38321/what-do-i-type-in-path-variable-for-adb-server-to-start-from-cmd/38324 ) (如果您不知道如何编辑路径系统变量,则为以下主题: https : //android.stackexchange.com/questions/38321/what-do-i-type-in​​-path-variable-for-adb-服务器从cmd / 38324启动 )

Then I run cmd again: react-native run-android 然后我再次运行cmd: react-native run-android

It worked for me. 它为我工作。


#5楼

I have faced the same problem with a real android device. 我在真正的android设备上也遇到过同样的问题。

Solution: Based on this answer by Niltoid 解决方案:基于Niltoid的回答

  1. Find your local IP 查找您的本地IP
  2. Open app and shake your Android device 打开应用并摇动您的Android设备
  3. Go Dev Setting and>Debug Server... 进行开发设置并>调试服务器...
  4. Paste your IP and port; 粘贴您的IP和端口; XXXX:8088" (where X's are your local IP) XXXX:8088“(其中X是您的本地IP)

for Mac user: open your network preference, here you will get your local IP. 对于Mac用户:打开您的网络偏好设置,在这里您将获得本地IP。


#6楼

If when running react-native run-android command the second line of the trace is 如果在运行react-native run-android命令时,跟踪的第二行是

JS server not recognized, continuing with build...

it means packager for the app cannot be started and the app will fail to load without some extra steps. 这意味着该应用的打包程序无法启动,并且如果没有一些额外的步骤,该应用将无法加载。 Note that the end of the trace still reports success: 请注意,跟踪结束仍报告成功:

BUILD SUCCESSFUL

The problem is probably some port conflict (in my case it was the default IIS site that I completely forgot about). 问题可能是端口冲突(在我的情况下,这是我完全忘记的默认IIS站点)。 Another manifestation of the problem would be a failure to open http://localhost:8081/debugger-ui URL in Chrome. 该问题的另一种表现可能是无法在Chrome中打开http://localhost:8081/debugger-ui URL。

Once the port conflict is resolved the trace will report 解决端口冲突后,将报告跟踪

Starting JS server...

then an additional Node window will open ( node ...cli.js start ) and the app will load/reload successfully. 然后将打开另一个Node窗口( node ...cli.js start ),该应用程序将成功加载/重新加载。

After that you should be able to open debug console in Chrome with http://localhost:8081/debugger-ui . 之后,您应该可以使用http://localhost:8081/debugger-ui在Chrome中打开调试控制台。

无法从Windows上的资产index.android.bundle加载脚本相关推荐

  1. 解决React Native unable to load script from assets index.android.bundle on windows

    React Native运行的时候,经常碰到React Native unable to load script from assets index.android.bundle on windows ...

  2. React Native之提示Unable to load script from assets ‘index.android.bundle

    1 问题 Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged cor ...

  3. Unable to load script from assets ‘index.android.bundle‘.

    打开React-Native项目,运行之后出现标题错误.百度之后的文章都是如下: 1.首先手动在android/app/src/main目录下建立一个assets文件夹2.然后在项目的根目录下执行 r ...

  4. android登陆加载加载_如何在Android上侧面加载应用

    android登陆加载加载 Just because an app isn't available from the Google Play Store doesn't mean it's not a ...

  5. react native unable to load script from sets “index.android.bundle“.make sure your bundle is packag

    unable to load script from sets "index.android.bundle".make sure your bundle is packaged c ...

  6. Android应用开发提高系列(4)——Android动态加载(上)——加载未安装APK中的类...

    前言 近期做换肤功能,由于换肤程度较高,受限于平台本身,实现起来较复杂,暂时搁置了该功能,但也积累了一些经验,将分两篇文章来写这部分的内容,欢迎交流! 关键字:Android动态加载 声明 欢迎转载, ...

  7. [转]Android应用开发提高系列(4)——Android动态加载(上)——加载未安装APK中的类...

    本文转自:http://www.cnblogs.com/over140/archive/2012/03/29/2423116.html 前言 近期做换肤功能,由于换肤程度较高,受限于平台本身,实现起来 ...

  8. Android高效加载大图、多图解决方案_LruCache,有效避免程序OOM

    本篇文章主要内容来自于Android Doc,我翻译之后又做了些加工,英文好的朋友也可以直接去读原文. http://developer.android.com/training/displaying ...

  9. android系统加载主题的流程,详解Android布局加载流程源码

    一.首先看布局层次 看这么几张图 我们会发现DecorView里面包裹的内容可能会随着不同的情况而变化,但是在Decor之前的层次关系都是固定的.即Activity包裹PhoneWindow,Phon ...

最新文章

  1. 测试Linux网卡是否正常工作
  2. linux安装PHP环境
  3. Linux0.11进程切换和TSS结构
  4. 【汇总】涉及iOSiPhone开发相关文章汇总
  5. Mac及Xcode常用快捷键
  6. python list sort by,python中List的sort方法指南
  7. Java统计每个大写字母的个数
  8. Halcon视觉框架+车牌识别+汉字识别+颜色识别+20200930
  9. 教程篇:《基础模块4》金蝶K3WISE15.0-客户端安装与卸载
  10. edoc2文档管理系统
  11. 第一章 网络入门【仅参考】
  12. 禁止每次打开edge自动在开始菜单创建Microsoft Edge 的 Edge 栏
  13. iOS 一步步带你实践组件二进制方案
  14. BaaS_后端即服务 RESTful
  15. Java开源 J2EE框架(二)
  16. mimikatz 使用
  17. 红魔风扇拆解原理和手册解读
  18. Java基础总结--面试答案个人总结
  19. UWB定位基站铺设原则简析
  20. 中国移动再现用户流失而推低价大流量套餐,但现有5G用户却得不到

热门文章

  1. Java、Node.js、PHP还是.Net? 无论你选谁,我都能教你一招!
  2. 怎么理解Condition
  3. iOS 如何在一个应用程序中调用另一个应用程序
  4. Hadoop2 自己动手编译Hadoop的eclipse插件
  5. WebService 出现因 URL 意外地以“/HelloWorld”结束,请求格式无法识别。
  6. Glut 回调函数小结
  7. 函数递归/二分法/列表,字典生成式/三元表达式/匿名函数/内置函数
  8. WinForm窗体重要属性与公共控件的重要属性
  9. poj题目分类(转)--方便分类做题
  10. SharePoint Web Service系列: Add或Update其他各种类型的项