react-native: Image not showing in release build, black color image only showing (Updated)

Environment

React Native Environment Info: System: OS: Windows 7 CPU: x64 Intel® Core™ i5-7400 CPU @ 3.00GHz Memory: 1.46 GB / 7.89 GB Binaries: Yarn: 1.9.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 5.6.0 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 3.1.0.0 AI-173.4907809

Description

It is working perfectly if I do not use images in the release build. In release build instead of images, showing only black space.

I am searching for this problem above one month and I found many answers and I tried all, but all are not working.

Tried answers

  1. react-native bundle --assets-dest ./android/app/src/main/res/ --entry-file ./App.js --bundle-output ./android/app/src/main/assets/index.android.bundle --platform android -dev false
  2. remove all image resizing code

Reproducible Demo

`import React, { Component } from ‘react’; import { Image } from ‘react-native’;

export default class App extends Component { render() { return ( <Image source={require(‘./a.png’)} /> ); } }`

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 15 (4 by maintainers)

Most upvoted comments

@radko93 Thanks for your response Now I have updated to the latest version and tried the same problem still found. The images are shown in “react-native run-android” command. But not showing when I run this command “react-native run-android --variant=release”.

If run the following command before the run-android, it shows “error duplicate resources” “react-native bundle --assets-dest ./android/app/src/main/res/ --entry-file ./App.js --bundle-output ./android/app/src/main/assets/index.android.bundle --platform android --dev false

react-native info : D:\cordova projects\React Native\NewApp>react-native info

React Native Environment Info: System: OS: Windows 7 CPU: x64 Intel® Core™ i5-7400 CPU @ 3.00GHz Memory: 1.46 GB / 7.89 GB Binaries: Yarn: 1.9.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 5.6.0 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 3.1.0.0 AI-173.4907809

It sounds like this has been resolved with the latest versions of tools. Let us know if you still run into this on the latest release.