反应原生Android启动画面

G. *_*ide 5 java android react-native

我正在尝试为Android RN应用程序构建启动画面.我按照这里描述的步骤操作:https://www.bignerdranch.com/blog/splash-screens-the-right-way/

不幸的是,在尝试启动我的应用程序时,构建成功但应用程序崩溃说:

Error type 3
Error: Activity class {com.needlios/com.needlios.MainActivity} does not exist.
Run Code Online (Sandbox Code Playgroud)

有谁知道这可能来自哪里?

我有以下代码:

SplashScreen.java

package com.needlios;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
        finish();
    }
}
Run Code Online (Sandbox Code Playgroud)

MainActivity.java

package com.needlios;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;

import java.util.Arrays;
import java.util.List;

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 "NeedlIOS";
    }

    /**
     * Returns whether dev mode should be enabled.
     * This enables e.g. the dev menu.
     */
    @Override
    protected boolean getUseDeveloperSupport() {
        return BuildConfig.DEBUG;
    }

   /**
   * A list of packages used by the app. If the app uses additional views
   * or modules besides the default ones, add more packages here.
   */
    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
        );
    }
}
Run Code Online (Sandbox Code Playgroud)

AndroidManifest.xml中

<activity
  android:name=".SplashActivity"
  android:label="@string/app_name"
  android:theme="@style/SplashTheme">
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)

G. *_*ide 4

好的,现在可以了。我刚刚将AndroidManifest.xml中的更改android:nameandroid:name=".MainActivity"

它有效,但我不明白为什么它会显示启动屏幕......