Skip to content Skip to sidebar Skip to footer

React-native : Can't Show Remote Images In Release Mode On Android Device

im runing a simple react-native application in my android device (samsung 9, Android 9, API 28), so on debug mode it's work fine using this commande line : react-native run-android

Solution 1:

Android pie (9) doesn't allow non https images to be rendered, so you have to change your http requests to https or to set a networkSecurityConfig in your Manifest application tag like this:

<?xml version="1.0" encoding="utf-8"?><manifest... ><applicationandroid:networkSecurityConfig="@xml/network_security_config"></application></manifest>

Then in your xml folder you now have to create a file named network_security_config just like the way you have named it in the Manifest and from there the content of your file should be like this to enable all requests without encryptions:

<?xml version="1.0" encoding="utf-8"?><network-security-config><base-configcleartextTrafficPermitted="true"><trust-anchors><certificatessrc="system" /></trust-anchors></base-config></network-security-config>

source: https://developer.android.com/training/articles/security-config

Solution 2:

We were having crashes and issues in development with our icons not being written out and appearing like images_homeactive. This caused react-native-navigation to crash our app

This occurred when we upgraded to compileSDKVersion = 28.

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

this prevents your application from connecting to the React Native packager. The changes below allow cleartext traffic in debug builds.

../app/src/main/AndroidManifest.xml
<application
    ...
    android:usesCleartextTraffic="${isDebug}" tools:targetApi="28">

../android/app/build.gradle
buildTypes {
    release {
        ...
        manifestPlaceholders = [isDebug:false]
    }
    debug {
        ...
        manifestPlaceholders = [isDebug:true]
    }
}

So thankful to stumble upon Ahmed's answer. Hope this helps someone.

Post a Comment for "React-native : Can't Show Remote Images In Release Mode On Android Device"