反应原生android错误

时间:2017-08-30 12:54:50

标签: android react-native exception-handling

我在反应原生

中开发了一个应用程序

它完美地运行在ios上 但在android中它有以下错误:

  

E / unknown:React:原生调用中的异常

     

java.lang.NullPointerException:尝试调用接口方法   ' java.util.Iterator java.util.List.iterator()'在null对象上   参考                                                                                在   com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:952)                                                                                在   com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:891)                                                                                在   com.facebook.react.ReactInstanceManager.access $ 600(ReactInstanceManager.java:104)                                                                                在   com.facebook.react.ReactInstanceManager $ ReactContextInitAsyncTask.doInBackground(ReactInstanceManager.java:218)                                                                                在   com.facebook.react.ReactInstanceManager $ ReactContextInitAsyncTask.doInBackground(ReactInstanceManager.java:197)                                                                                在android.os.AsyncTask $ 2.call(AsyncTask.java:304)                                                                                在java.util.concurrent.FutureTask.run(FutureTask.java:237)                                                                                在   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)                                                                                在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:607)                                                                                在java.lang.Thread.run(Thread.java:761)

我如何解决这个问题?为什么会出现这个问题?

1 个答案:

答案 0 :(得分:0)

我改变RNSpinkitPackage类,如下所示,它在android中完全像ios一样工作:

public class RNSpinkitPackage implements ReactPackage{
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
    return Collections.emptyList();
}

@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}

@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    List<ViewManager> list = new ArrayList<>();
    list.add(new RNSpinkit(reactContext));
    return list;
}

}