1

I'm following the steps described on React native documentation

https://facebook.github.io/react-native/docs/integration-with-existing-apps.html

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mReactRootView = new ReactRootView(this);
    mReactInstanceManager = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setBundleAssetName("index.android.bundle")
            .setJSMainModuleName("index.android")
            .addPackage(new MainReactPackage())
            .setUseDeveloperSupport(BuildConfig.DEBUG)
            .setInitialLifecycleState(LifecycleState.RESUMED)
            .build();
    mReactRootView.startReactApplication(mReactInstanceManager, "HelloWorld", null);

    setContentView(mReactRootView);
}

However, when I try do use the Component Image with images from my android assets, it is not showing.

https://facebook.github.io/react-native/docs/images.html#images-from-hybrid-app-s-resources

Anyone was integrated a react native app into an Android Application and used images from Assets?

I tried

<Image source={{uri:'file:///data/data/com.sampleproject/files/blankProject2/0.1/img/sample.jpeg'}} style={{width: 300, height: 300}}/>

and

<Image source={{uri: 'img_sample.jpeg'}} />

Both situation failed.

Oximer
  • 548
  • 5
  • 19

1 Answers1

0

If you are using Android you should do it like this to load images from assets:

<Image source={{uri: 'asset:/app_icon.png'}} style={{width: 40, height: 40}} />

with asset:/ prefixing the image name