嗨我用这篇文章来改变我的启动画面for android via react native但是我有这个错误: 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
**并且看不到反应原生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
作出反应。
答案 0 :(得分:1)
开始新鲜,让我们一步一步走。
react-native start
)注意:
如果手机通过USB连接,请连接您的系统和 电话 使用相同的wifi,否则运行adb reverse tcp:8081 tcp:8081
干杯:)