2

Attempting to create an Android view to use in ReactNative later on.

This is the code that I wrote following the official tutorial, but I'm still getting some troubles compiling.

Here is the error message that I get:

Error:(15, 53) error: constructor ReactImageView in class ReactImageView cannot be applied to given types;
required: Context,AbstractDraweeControllerBuilder,GlobalImageLoadListener,Object
found: no arguments
reason: actual and formal argument lists differ in length

Here instead is the code:

package com.androidbridge;

import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.views.image.ReactImageView;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.drawee.backends.pipeline.Fresco;
import javax.annotation.Nullable;

public class ReactImageManager extends SimpleViewManager<ReactImageView> {

    public static final String REACT_CLASS = "RCTImageView";

    private Object mCallerContext;

    public ReactImageManager(Object mCallerContext) {
        this.mCallerContext = mCallerContext;
    }

    @Override
    public String getName() {
        return REACT_CLASS;
    }

    @Override
    protected ReactImageView createViewInstance(ThemedReactContext reactContext) {
        return new ReactImageView(reactContext, Fresco.newDraweeControllerBuilder(), mCallerContext);
   }
}

I am kind of lost as the code is derived from the official tutorial.

mm24
  • 9,280
  • 12
  • 75
  • 170

1 Answers1

0

It seems like the signature of the class ReactImageView has changed since the tutorial was written, the constructor now also require you to pass an object of type GlobalImageLoadListener. It is marked as nullable as of the latest react-native version, so you can try just passing a null reference.

I just got started myself and find the tutorial somewhat lacking.

quist
  • 1
  • 1
  • 1