Not working with modified MainActivity for react-native-navigation
Unfortunately the app crash on launch. Maybe this is due to the fact that the mainactivity class has been modified which extends the SplashActivity from com.reactnativenavigation.controllers.SplashActivity rather than the old school ReactActivity class.
Yes, I'm using the react-native-navigation by wix (https://github.com/wix/react-native-navigation)
Here's the full code of my MainActivity.java, maybe I'm just doing something wrong.
import org.devio.rn.splashscreen.SplashScreen;
import com.reactnativenavigation.controllers.SplashActivity;
import android.os.Bundle;
public class MainActivity extends SplashActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this); // here
super.onCreate(savedInstanceState);
}
}
If anyone had a similar problem, please let me know for any solution thanks.
Still the same error.:(
"react-native": "0.57.3", "react-native-splash-screen": "^3.1.1", "react-native-navigation": "^1.1.490",
The app can't run on Android but work well on iOS. And I am using react-native-navigation and set values/colors.xml. Here is my code.
Can anyone help me? Thanks a lot~~
================MainActivity.java===========================
package com.myApp;
import android.os.Bundle;
import com.reactnativenavigation.controllers.SplashActivity;
import org.devio.rn.splashscreen.SplashScreen;
public class MainActivity extends SplashActivity {
@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 "myApp";
}
}
=================values/colors.xml===============================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary_dark">#660B0B0B</color>
</resources>
This is my Mainactivity code and its working
package com.actnursesportal; import android.os.Bundle; import com.reactnativenavigation.NavigationActivity; import org.devio.rn.splashscreen.SplashScreen;
public class MainActivity extends NavigationActivity { @Override protected void onCreate(Bundle savedInstanceState) { SplashScreen.show(this); // here super.onCreate(savedInstanceState); }
}
My main issue was having a white screen between splash screen and my progress indicator
So I googled and found people saying that this library fixes that issue.
But when I followed the manual setup and getting started my app crashes at the start. when I comment SplashScreen.show(this) it works but with the white screen appearing.
Here is my MainActivity.Java
`package com.goldenapp; import android.os.Bundle; // here import com.facebook.react.ReactActivity; import org.devio.rn.splashscreen.SplashScreen; // here
public class MainActivity extends ReactActivity { @Override protected void onCreate(Bundle savedInstanceState) { SplashScreen.show(this); // here 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 "GoldenApp"; } }`
My MainApplication.Java `package com.goldenapp;
import android.app.Application;
import com.facebook.react.ReactApplication; import com.oblador.vectoricons.VectorIconsPackage; import com.brentvatne.react.ReactVideoPackage; import com.reactnative.ivpusic.imagepicker.PickerPackage; import com.agontuk.RNFusedLocation.RNFusedLocationPackage; import com.airbnb.android.react.maps.MapsPackage; import cl.json.RNSharePackage; import org.reactnative.camera.RNCameraPackage; import com.imagepicker.ImagePickerPackage; import com.babisoft.ReactNativeLocalization.ReactNativeLocalizationPackage; import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.entria.views.RNViewOverflowPackage; import org.devio.rn.splashscreen.SplashScreenReactPackage; // import com.babisoft.ReactNativeLocalization.ReactNativeLocalizationPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import com.devfd.RNGeocoder.RNGeocoderPackage; import java.util.Arrays; 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() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new VectorIconsPackage(),
new ReactVideoPackage(),
new PickerPackage(),
new RNFusedLocationPackage(),
new MapsPackage(),
new RNSharePackage(),
new RNCameraPackage(),
new ImagePickerPackage(),
new ReactNativeLocalizationPackage(),
new RNDeviceInfo(),
new RNGeocoderPackage(),
new RNViewOverflowPackage(),
new SplashScreenReactPackage()
// new ReactNativeLocalizationPackage()
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
@Override public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); } } `
My colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="blue">#4F6D7A</color>
<color name="primary_dark">#4F6D7A</color>
</resources>
My styles.xml
`
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:statusBarColor">@color/blue</item>
</style>
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
`