skip to Main Content

Error loading page
Domain:undefined
Error Code:-2
Description:net::ERR_NAME_NOT_RESOLVED

Getting this issue in release apk in android react native

I already used android:usesCleartextTraffic="true" in menifest file

2

Answers


  1. In release apk may be android is unable to find the path of your html file.

    Login or Signup to reply.
  2. To properly load a local HTML file (e.g., index.html) in your React Native WebView, you need to ensure that the file is placed in the correct directory and referenced correctly in your code.

    1. Place the HTML File in the Correct Directory:
      • Move your index.html file to the following path in your Android project:

    android/app/src/main/assets/

    1. Reference the Local HTML File in WebView:
    • Use the following code snippet to load the local HTML file in your WebView:

    Explanation:

    • File Path: The path

    file:///android_asset/index.html

    is used to reference the HTML file in the assets folder on Android. This path is recognized by the Android system during the release build.

    • Platform Check: The code includes a platform check to ensure compatibility with both iOS and Android. For iOS, you can use require to load the HTML file directly.

    Additional Notes:

    • Ensure that you have added

    android:usesCleartextTraffic="true"

    in your AndroidManifest.xml if you are also loading any HTTP content.

    • If you continue to experience issues, double-check the file name and path to ensure they are correct.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search