React Native 0.60.5 react-native-splash-screen 配置 android

React Native 0.60.5 react-native-splash-screen configuration android

当我在设置库时,按照那里所说的进行操作:https://github.com/crazycodeboy/react-native-splash-screen 我发现在 MainActivity.java 中不再有 onCreate 方法。

MainActivity.java RN 0.60

package com.testApp;

import com.facebook.react.ReactActivity;

public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "testApp";
    }
}

所以我尝试在 getMainComponentName 方法中进行设置: MainActivity.java

package com.testApp;

import com.facebook.react.ReactActivity;
import org.devio.rn.splashscreen.SplashScreen;

public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */

    @Override
    protected String getMainComponentName() {
        SplashScreen.show(this);
        return "testApp";
    }
}

但是当我尝试编译时它给了我这个错误:error: cannot find symbol variable SplashScreen

有人知道怎么做吗?

重写 MainActivity 中的 onCreate 方法,像这样:

@Override
    protected void onCreate(Bundle savedInstanceState){
        SplashScreen.show(this);
        super.onCreate(savedInstanceState);
    }

别忘了 import android.os.Bundleimport org.devio.rn.splashscreen.SplashScreen;