异常调用对象作为AppRegistry.runApplication中的函数

时间:2018-01-05 06:16:14

标签: android react-native react-native-android

我的React原生Android应用程序中有一些错误,特别是在启动代码中。

import React from 'react';
import { AppRegistry } from 'react-native';
import { Provider } from 'react-redux';
import codePush from 'react-native-code-push';
import App from './src/App';
import store from './src/store/store';

const Wrapper = () => (
    <Provider store={store}>
        <App />
    </Provider>
);

AppRegistry.registerComponent('myApp', () => Wrapper);

我在React native中遇到以下红屏错误。 enter image description here

我粘贴了MainApplication.java代码 - 以防万一有用。

package com.myapp;

import android.app.Application;
import com.facebook.react.ReactApplication;
import com.BV.LinearGradient.LinearGradientPackage;
import com.RNFetchBlob.RNFetchBlobPackage;
import com.horcrux.svg.SvgPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.microsoft.codepush.react.CodePush;
import com.facebook.soloader.SoLoader;
import com.clevertap.android.sdk.ActivityLifecycleCallback;
import com.clevertap.react.CleverTapPackage;
import java.util.Arrays;
import java.util.List;


public class MainApplication extends Application implements ReactApplication {

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {

        /* protected String getJSBundleFile() {
            return CodePush.getJSBundleFile();
        } */

        @Override
        public boolean getUseDeveloperSupport() {
            return BuildConfig.DEBUG;
        }

        @Override
        protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
                new RNDeviceInfo(),
                new LinearGradientPackage(),
                new SvgPackage(),
                new RNFetchBlobPackage(),
                new CleverTapPackage()
                // new CodePush("KbxkSGsHBP8juy8-du9vt9QHaJ75r1BshsUMf", getApplicationContext(), BuildConfig.DEBUG)
            );
        }

        @Override
        protected String getJSMainModuleName() {
            return "index.android";
        }
  };

    @Override
    public ReactNativeHost getReactNativeHost() {
        return mReactNativeHost;
    }

    @Override
    public void onCreate() {
        ActivityLifecycleCallback.register(this);
        super.onCreate();
        SoLoader.init(this, /* native exopackage */ false);
    }

}

日志在这里:

--------- beginning of system
--------- beginning of main
D/ReactNative( 3029): ReactInstanceManager.ctor()
D/ReactNative( 3029): ReactInstanceManager.createReactContextInBackground()
D/ReactNative( 3029): ReactInstanceManager.recreateReactContextInBackgroundInner()
D/ReactNative( 3029): ReactInstanceManager.onJSBundleLoadedFromServer()
D/ReactNative( 3029): ReactInstanceManager.recreateReactContextInBackground()
D/ReactNative( 3029): ReactInstanceManager.runCreateReactContextOnNewThread()
D/ReactNative( 3029): ReactInstanceManager.createReactContext()
D/ReactNative( 3029): Initializing React Xplat Bridge.
D/ReactNative( 3029): Initializing React Xplat Bridge before initializeBridge
D/ReactNative( 3029): Initializing React Xplat Bridge after initializeBridge
D/ReactNative( 3029): CatalystInstanceImpl.runJSBundle()
D/ReactNative( 3029): ReactInstanceManager.setupReactContext()
D/ReactNative( 3029): CatalystInstanceImpl.initialize()
D/ReactNative( 3029): ReactInstanceManager.attachRootViewToInstance()
I/ReactNativeJS( 3029): [CodePush] The CodePush module doesn't appear to be properly installed. Please double-check that everything is setup correctly.
W/ReactNativeJS( 3029): Warning: Native component for "RCTView" does not exist
W/ReactNativeJS( 3029): Warning: Native component for "RCTImageView" does not exist
W/ReactNativeJS( 3029): Warning: Native component for "RCTTextInlineImage" does not exist
W/ReactNativeJS( 3029): Warning: Native component for "RCTPdf" does not exist
I/ReactNativeJS( 3029): Running application "kalhattiApp" with appParams: {"rootTag":1}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
W/ReactNativeJS( 3029): Warning: Failed prop type: Maximum call stack size exceeded.
W/ReactNativeJS( 3029):     in View (at UnimplementedView.js:33)
W/ReactNativeJS( 3029):     in UnimplementedView (at View.js:113)
W/ReactNativeJS( 3029):     in View (at UnimplementedView.js:33)
W/ReactNativeJS( 3029):     in UnimplementedView (at View.js:113)
W/ReactNativeJS( 3029):     in View (at UnimplementedView.js:33)
W/ReactNativeJS( 3029):     in UnimplementedView (at View.js:113)
...
...
[deleted similar lines]
...
...
W/ReactNativeJS( 3029):     in View (at UnimplementedView.js:33)
W/ReactNativeJS( 3029):     in UnimplementedView (at View.js:113)
W/ReactNativeJS( 3029):     in View (at
E/ReactNativeJS( 3029): Maximum call stack size exceeded.

1 个答案:

答案 0 :(得分:0)

我错过了在包列表中添加MainReactPackage!

我可能忽略了它或者误删了它。