在更新到React Native 0.18后尝试让模块正常工作时,我收到以下错误:
com.lwansbrough.RCTCamera.RCTCameraViewManager无法转换为 com.facebook.react.uimanager.ViewGroupmanager
导致此类错误的原因是什么,以及如何解决?
以下是RCTCameraViewManager的代码:
package com.lwansbrough.RCTCamera;
import android.support.annotation.Nullable;
import com.facebook.react.uimanager.*;
public class RCTCameraViewManager extends SimpleViewManager<RCTCameraView> {
private static final String REACT_CLASS = "RCTCameraView";
@Override
public String getName() {
return REACT_CLASS;
}
@Override
public RCTCameraView createViewInstance(ThemedReactContext context) {
return new RCTCameraView(context);
}
@ReactProp(name = "aspect")
public void setAspect(RCTCameraView view, int aspect) {
view.setAspect(aspect);
}
@ReactProp(name = "captureMode")
public void setCaptureMode(RCTCameraView view, int captureMode) {
// TODO - implement video mode
}
@ReactProp(name = "captureTarget")
public void setCaptureTarget(RCTCameraView view, int captureTarget) {
// No reason to handle this props value here since it's passed again to the RCTCameraModule capture method
}
@ReactProp(name = "type")
public void setType(RCTCameraView view, int type) {
view.setCameraType(type);
}
@ReactProp(name = "torchMode")
public void setTorchMode(RCTCameraView view, int torchMode) {
view.setTorchMode(torchMode);
}
@ReactProp(name = "flashMode")
public void setFlashMode(RCTCameraView view, int flashMode) {
view.setFlashMode(flashMode);
}
@ReactProp(name = "orientation")
public void setOrientation(RCTCameraView view, int orientation) {
view.setOrientation(orientation);
}
@ReactProp(name = "captureAudio")
public void setCaptureAudio(RCTCameraView view, boolean captureAudio) {
// TODO - implement video mode
}
}
答案 0 :(得分:2)
我也遇到了这个错误,我的解决方案是改变
public class RCTCameraViewManager extends SimpleViewManager<RCTCameraView>
到
public class RCTCameraViewManager extends ViewGroupManager<RCTCameraView>