无法从资产“index.android.bundle"加载脚本. [英] Unable to load script from assets 'index.android.bundle'.

查看:42
本文介绍了无法从资产“index.android.bundle"加载脚本.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 ./gradlew assembleDebug 构建 apk 后收到此错误.如果我使用 ./gradlew assembleRelease 构建 apk,我会在手机上安装应用程序时出错.当我使用 react-native run-android 在虚拟设备中运行相同的应用程序时,应用程序运行良好,没有任何问题.有什么想法吗?

I get this error after building apk with ./gradlew assembleDebug. If I build apk with ./gradlew assembleRelease, I get an error on install app on mobile phone. When I run same app in virtual device with react-native run-android, app is working fine without any troubles. Any ideas?

  "dependencies": {
    "react": "16.2.0",
    "react-native": "0.52.0",
    "react-navigation": "^1.0.0-beta.27"
  },
  "devDependencies": {
    "babel-jest": "22.1.0",
    "babel-preset-react-native": "4.0.0",
    "jest": "22.1.1",
    "react-test-renderer": "16.2.0",
    "util": "^0.10.3"
  },

推荐答案

以下是我需要您遵循的步骤来解决此问题.

Here are the steps i need you to follow to solve this issue.

删除android文件夹并进行react-native升级(不是react-native run-android)

Delete android folder and do react-native upgrade (not react-native run-android)

在以下位置创建文件夹.

create the folder in the following location.

your_app/android/app/src/main

在根目录下执行以下命令.(只需复制并粘贴以下代码)

Perform the following command in root directory. (simply copy and paste the below code)

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/

请注意如果您使用的是 index.android.js,请在 --entry-file 中替换它.

Please note if you are using index.android.js then replace it in --entry-file.

最后

cd android && ./gradlew installDebug

希望这能解决您的问题.

Hope this solves your solution.

这篇关于无法从资产“index.android.bundle"加载脚本.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆