1

React Native Image is not showing. What is the reason. I checked several answers on stackoverflow, but no answer helped me.

The problem is that image doesn't show on android, but on iOS. What is the reason? That is my code.

import React, { Component } from 'react';
import { View, Image } from 'react-native';

export default class ImageTest extends Component {
  constructor(props) {
    super(props);
    this.state = {
    };
  }

  render() {
    return (
      <View style={{ flex: 1 }}>
        <Image
          source={{ uri: 'https://reactnative.dev/img/tiny_logo.png' }}
          style={{ width: 200, height: 100, resizeMode: 'stretch' }} />
        <Image
          source={require('../assets/logo.png')}
          style={{ width: 200, height: 100, resizeMode: 'stretch' }} />
        <Image
          style={{ width: 200, height: 100, resizeMode: 'stretch' }}
          source={{
            uri:
              'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAYAAAA6oTAqAAAAEXRFWHRTb2Z0d2FyZQBwbmdjcnVzaEB1SfMAAABQSURBVGje7dSxCQBACARB+2/ab8BEeQNhFi6WSYzYLYudDQYGBgYGBgYGBgYGBgYGBgZmcvDqYGBgmhivGQYGBgYGBgYGBgYGBgYGBgbmQw+P/eMrC5UTVAAAAABJRU5ErkJggg==',
          }}
        />
      </View>
    );
  }
}
SatelBill
  • 641
  • 2
  • 12
  • 28
  • are you building to iOS 14 with old react native version and latest xcode? – Horst Sep 28 '20 at 07:09
  • Thanks. iOS 11, React Native 0.63.2, latest xcode – SatelBill Sep 28 '20 at 07:19
  • Please, remove your second image, ` ` and test like that. I want to make sure if you're experiencing problems with `Image` or local files. – knoxgon Sep 28 '20 at 07:26
  • Still not working. Maybe the reason isn't anything else? And I am not sure how iOS is working well. – SatelBill Sep 28 '20 at 07:32
  • I tested your code and it works fine with no problems. What version of react and react-native are you using? – knoxgon Sep 28 '20 at 07:33
  • "react": "16.13.1", "react-native": "0.63.2", – SatelBill Sep 28 '20 at 07:36
  • Read and test this. https://stackoverflow.com/questions/39385129/react-native-images-not-showing-in-android-device-but-shows-perfectly-in-emula – knoxgon Sep 28 '20 at 07:37
  • is it release build or debug one? – Piyush Sep 28 '20 at 07:48
  • Debug mode. Ohh,, Thank you. Working well. – SatelBill Sep 28 '20 at 07:52
  • Hello, Volkan, Thanks for your answer. I checked the URL you sent just before. [link](https://stackoverflow.com/questions/39385129/react-native-images-not-showing-in-android-device-but-shows-perfectly-in-emula) I followed that answer, then on real device, it's working well, but android emulator is not working. – SatelBill Sep 28 '20 at 07:57
  • @SatelBill Android emulator is in itself a problematic environment. I've had more than a dozen problems with the emulator. Usually, micro things. Do you have a chance to build and run your code in Expo instead? With Expo, you can instant-test your code in a real device which actually matters. – knoxgon Sep 28 '20 at 08:05
  • Yes. Actually it didn't worked both emulator and android real device. Just it worked on iOS. But as the result of following this answer, It worked on real device. Now only android emulator is not showing image. – SatelBill Sep 28 '20 at 08:08
  • **react-native bundle --platform android --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --dev false --reset-cache --assets-dest android/app/src/main/res/** In this command, what does "--dev false" mean? If I set this "--dev true", Will that work on android emulator? – SatelBill Sep 28 '20 at 08:16
  • --dev false means developer mode to be false. Indicates release mode. – knoxgon Sep 28 '20 at 08:25

0 Answers0