Splash screen still doesn't load first in React Native app
Step 1
For android: /android/app/src/main/res/layout add an xml file called launch_screen.xml and have the code in it like that:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/gatepasssplash" android:scaleType="centerCrop" />
</RelativeLayout>
Step 2
inside android\app\src\main\java\MainActivity.java add two lines on top as below:
import android.os.Bundle;
import org.devio.rn.splashscreen.SplashScreen;
and add
public class MainActivity extends ReactActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this);
super.onCreate(savedInstanceState);
}
Build the app!
-------------------------------------------------------------------------------------------------------------------------
If showing build failed then please follow below steps:
on your project root in cmd go inside android folder by adding cd android
then run ./gradlew clean and build again.
Still problem then run on your project root npm install
it will reinstall all nodes pakcage and hopefully it will start working now.
Comments
Post a Comment