React Native - 启动画面更改错误

React Native - Splash Screen Changing Error

您好,我使用这篇文章通过本机反应更改了 android 的启动画面,但我遇到了这个错误: Article link

  BUILD SUCCESSFUL  
Total time: 1 mins 43.179 secs
Running C:\Users\Saeed\AppData\Local\Android\sdk/platform-tools/adb -s 5203fc0e586a3409 reverse tcp:8081 tcp:8081
Starting the app on 5203fc0e586a3409 (C:\Users\Saeed\AppData\Local\Android\sdk/platform-tools/adb -s 5203fc0e586a3409 shell am start -n com.mohajerkade/.MainActivity)...
Starting: Intent { cmp=com.mohajerkade/.MainActivity VirtualScreenParam=Params{mDisplayId=-1, null, mFlags=0x00000000)} }
Error type 3
Error: Activity class {com.mohajerkade/com.mohajerkade.MainActivity} does not exist.
events.js:160
      throw er; // Unhandled 'error' event
      ^
Error: spawn cmd.exe ENOENT
    at exports._errnoException (util.js:1022:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

首先我有启动画面 3 秒然后**我的手机出现红屏Error calling AppRegistry.runApplication并且看不到 React Native Hello World

这是我的 MainActivity.java :

package com.mohajerkade;

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

这是SplashActivity.java:

    package com.mohajerkade;

import com.facebook.react.ReactActivity;
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();
    }
}

我使用了这个 Toturial,但我不知道我应该如何在应用程序加载中看到启动画面,然后反应本机 Hello World

重新开始,让我们一步步来。

  • 从您的 phone
  • 中删除以前的应用
  • 启动服务器 (react-native start)
  • 在您的 android 工作室中按下 运行 按钮
  • 之后从您的应用打开开发者菜单
  • 通过转到调试服务器主机选项来设置您的本地主机(IP address:8081) 设备。
  • 重新加载,一切顺利。

注:

If the phone is connected through USB then connect your system and phone with same wifi, else run adb reverse tcp:8081 tcp:8081

干杯:)