Unable to load script from assets index.android.bundle on windows

后端 未结 30 3587
鱼传尺愫
鱼传尺愫 2020-11-22 06:33

I\'m trying to run my first React Native project for first time on my device (Android 4.2.2).

And I get:

unable to load script from assets in

30条回答
  •  -上瘾入骨i
    2020-11-22 07:08

    I have just encounterred exactly the same problem and solved it. So hope to be helpful.

    Suppose you are assemblling a release application package (.apk)

    1. Check if your assets folder exist?: \android\app\src\main\assets If not, create one.

    2. After executing "Assemble Release", check if there is anything in that folder(\android\app\src\main\assets) If not, find js bundle file(index.android.bundle), which should be in more than one of the following paths:

      *a)\android\app\build\intermediates\merged_assets\release\out\index.android.bundle

      b)\android\app\build\intermediates\merged_assets\release\mergeReleaseAssets\out\index.android.bundle

      c)\android\app\build\intermediates\assets\release\index.android.bundle

      d)\android\app\build\generated\assets\react\release\index.android.bundle*

    A better way is to use "Everything" to search the file name: index.android.bundle.

    1. Then copy this file into your assets folder(\android\app\src\main\assets\index.android.bundle)

    2. Go back to powershell or command console, execute:

    react-native run-android --variant=release

    It should work.

    Good luck!

提交回复
热议问题