White screen still showing on android
See original GitHub issueFollowing the steps for android setup still led to a white screen. Below are concerned files:
“pod”: “^0.9.0”, “react”: “16.9.0”, “react-native”: “0.61.5”, “react-native-splash-screen”: “^3.2.0”,
Android Manifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.solvicles">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE"/>
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<!-- android:screenOrientation="portrait" -->
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
Java files:
MainActivity:
package com.solvicles;
import android.os.Bundle;
import com.facebook.react.ReactActivity;
import org.devio.rn.splashscreen.SplashScreen
;
public class MainActivity extends ReactActivity {
@Override
protected void onCreate(Bundle savedInstanceState){
SplashScreen.show(this);
super.onCreate(savedInstanceState);}
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "Solvicles";
}
}
MainApplication:
package com.solvicles;
import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import org.devio.rn.splashscreen.SplashScreenReactPackage;
import org.reactnative.maskedview.RNCMaskedViewPackage;
import com.BV.LinearGradient.LinearGradientPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this); // Remove this line if you don't want Flipper enabled
}
/**
* Loads Flipper in React Native templates.
*
* @param context
*/
private static void initializeFlipper(Context context) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
SplashActivity:
package com.solvicles;
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle saveInstanceState){
super.onCreate(saveInstanceState);
Intent intent= new Intent(this, MainActivity.class);
startActivity(intent);
finish();
}
}
XML files:
background_splash.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/black"/>
<item
android:width="150dp"
android:height="200dp"
android:drawable="@mipmap/logo"
android:gravity="center"
/>
</layer-list>
font.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/black"/>
<item
android:width="150dp"
android:height="200dp"
android:drawable="@mipmap/logo"
android:gravity="center"
/>
</layer-list>
launch_screen.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
android:gravity="center">
<ImageView
android:layout_width="300dp"
android:layout_height="400dp"
android:src="@mipmap/logo" />
<TextView
android:layout_width="184dp"
android:layout_height="wrap_content"
android:fontFamily="@font/font"
android:fontWeight="200"
android:paddingLeft="35dp"
android:paddingTop="100dp"
android:text="Solvicles"
android:textColor="#FFFFFF"
android:textSize="27sp"></TextView>
</LinearLayout>
colors.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black" >#000000</color>
<color name="primary_dark" >#000000</color>
</resources>
strings.xml:
<resources>
<string name="app_name">Solvicles</string>
</resources>
styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:textColor">#000000</item>
</style>
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
</resources>
The icon name on mipmap is logo
App.js:
i``` mport React, {Component} from ‘react’; import { SafeAreaView, StyleSheet, ScrollView, View, Text, StatusBar, Image, TouchableOpacity, Platform
} from ‘react-native’; import LinearGradient from ‘react-native-linear-gradient’; import Omni from ‘./Omni.js’ import { observer } from “mobx-react” import RNSplashScreen from ‘react-native-splash-screen’
@observer class App extends React.Component{
componentDidMount(){ RNSplashScreen.hide() StatusBar.setHidden(true, ‘none’)
}
render(){
return(
<Omni/>) } }
export default App;
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top GitHub Comments
Okay, I solved it:
So as you can see, after
SplashScreen.hide()
I’m manually navigating to another screen (which in my case is the login screen). This solved the problem of the white screen still showing on Android. Also, the reason why I have thatrender()
and just rendering an empty view is that without it, the app was crashing. Hope this helps!Oh great! Glad to hear that your problem has been fixed! 👍