React-native: React Native app shows 'index.android.bundle' error when setting targetSdkVersion to 28

Created on 12 Feb 2019  ·  9Comments  ·  Source: facebook/react-native

🐛 Bug Report

After I updated my targetSdkVersion from 27 to 28, I ran react-native run-android connected to an emulator and was presented with a screen stating "Unable to load script from assets 'index.android.bundle'. Make sure your bundle packaged correctly or you're running a package server."

To Reproduce

From a new or existing (functioning) React Native app, change the targetSdkVersion in android/build.gradle file to 28.

Expected Behavior

The app loads as it did before.

Environment

  React Native Environment Info:
    System:
      OS: Linux 4.4 Ubuntu 16.04.5 LTS (Xenial Xerus)
      CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
      Memory: 17.71 GB / 31.87 GB
      Shell: 4.3.48 - /bin/bash
    Binaries:
      Node: 8.15.0 - ~/.nvm/versions/node/v8.15.0/bin/node
      Yarn: 1.12.3 - /usr/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v8.15.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      Android SDK:
        API Levels: 23, 24, 25, 26, 28
        Build Tools: 25.0.0, 28.0.3
        System Images: android-28 | Intel x86 Atom_64
    npmPackages:
      react: 16.6.3 => 16.6.3
      react-native: 0.58.3 => 0.58.3
    npmGlobalPackages:
      react-native-cli: 2.0.1
Bug Android Linux Locked 📦Bundler

Most helpful comment

Starting with Android 9.0 (API level 28), cleartext support is disabled by default.

AndroidManifest.xml file change as following

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        ...
        android:usesCleartextTraffic="true"
        ...>
        ...
    </application>
</manifest>

All 9 comments

+1 on Windows 10

I think that It could be related to this issue: https://github.com/facebook/react-native/issues/23349#event-2130706843

Same problem after upgrading from RN 57.7 to 58.5

i had a same problme
and fixed by this link

I ran into the same type of error with the bundle not being found. My issue was fixed by changing the gradle version I was using. I made a comment about this here https://github.com/facebook/react-native/issues/23739#issuecomment-469417259. Hopefully, the solution I used will work for someone else 😄

我升级28以后,在Android9.0系统上 ,text多行显示时,最后一行显示一半,好像整个text不计算行间距似的,这是怎么回事

I ran into the same problem with a project I upgraded to 0.59, so I thought the upgrading went wrong.

After creating a new project with react-native init I ran into the same problem when trying to run it on android simulator or a physical device.

I followed the instructions mentioned here https://stackoverflow.com/questions/44446523/unable-to-load-script-from-assets-index-android-bundle-on-windows/44476757#44476757 (as @mr-niri posted) and this resolved my issue.

Output of react-native info

info
  React Native Environment Info:
    System:
      OS: macOS 10.14.3
      CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
      Memory: 276.07 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 5.6.0 - ~/.nvm/versions/node/v8.11.3/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 27, 28
        Build Tools: 27.0.3, 28.0.3
        System Images: android-28 | Google Play Intel x86 Atom
    IDEs:
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.1 => 0.59.1

Duplicate of #22024.

Starting with Android 9.0 (API level 28), cleartext support is disabled by default.

AndroidManifest.xml file change as following

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        ...
        android:usesCleartextTraffic="true"
        ...>
        ...
    </application>
</manifest>
Was this page helpful?
0 / 5 - 0 ratings