react-native-splash-screen icon indicating copy to clipboard operation
react-native-splash-screen copied to clipboard

Not working with modified MainActivity for react-native-navigation

Open kennethpdev opened this issue 9 years ago • 23 comments

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.

kennethpdev avatar Nov 19 '17 19:11 kennethpdev

Same problem :/

MisterAlex95 avatar Nov 21 '17 10:11 MisterAlex95

I use it know : https://github.com/react-native-component/react-native-smart-splash-screen .. And it's working

MisterAlex95 avatar Nov 22 '17 12:11 MisterAlex95

@MisterAlex95 it worked for you? can you show me your MainActivity.java

kennethpdev avatar Nov 22 '17 12:11 kennethpdev

Same problem, and I wondered which step was wrong until saw this issue...

amiku avatar Nov 22 '17 12:11 amiku

import android.content.Intent;
import android.os.Bundle;
import com.facebook.react.ReactActivity;
import com.reactnativenavigation.controllers.SplashActivity;
import com.reactnativecomponent.splashscreen.RCTSplashScreen;

public class MainActivity extends SplashActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      RCTSplashScreen.openSplashScreen(this);
      super.onCreate(savedInstanceState);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
    }
}

@kenma9123

MisterAlex95 avatar Nov 22 '17 16:11 MisterAlex95

@MisterAlex95 that's a different splash screen library. That's react-native-splashscreen by remobile not react-native-splash-screen by crazycodeboy. But I probably try that if it really works.

kennethpdev avatar Nov 22 '17 16:11 kennethpdev

Oh yeah sorry, bad link in my msg !, i've edit the msg.

MisterAlex95 avatar Nov 22 '17 17:11 MisterAlex95

Same problem here

hbarylskyi avatar Nov 23 '17 14:11 hbarylskyi

I can confirm @MisterAlex95 method works on RN .47.1 with this splash plugin https://github.com/react-native-component/react-native-smart-splash-screen

die20 avatar Nov 25 '17 18:11 die20

Same problem here

yewenxiang23 avatar Nov 30 '17 08:11 yewenxiang23

Hello Guys ... I am having the same problem ... App crashes on startup ... I have followed the installation steps correct .... here is my MainActivity.java. I am not sure what is the issue here .

package com.testapp;

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

Base29 avatar Dec 04 '17 19:12 Base29

I'm no longer experiencing the problem, but not sure what helped. @Base29, try running adb logcat and have a look at error stacktrace. Also what's your react-native and react-native-splash-screen versions?

hbarylskyi avatar Dec 04 '17 21:12 hbarylskyi

@Barylskyigb ... Thanks for the reply ... My react native version is 0.50.4 and I have installed react-native-splash-screen using npm install so I believe it is the latest one 3.0.6 ... The issue somehow generated when I initiate SplashScreen.show(this) in the onCreate method ... When i remove SplashScreen.show(this) the app starts normally ofcourse without a splash screen ... what could be that I am doing wrong here ? Also I will run logcat and will get back to you.

Base29 avatar Dec 05 '17 05:12 Base29

@Base29 same as you, But I have using react-native-navigation, I don't know library can compatible. By I find a solution that we will implement on native code of ios, android.

react native version is 0.50.4 react version 16.0.0 react-native-splash-screen version ^3.0.6 react-native-navigation version ^1.1.298

voratham avatar Dec 07 '17 02:12 voratham

@voratham ... Thanks for the reply ... I have tried so many things but can't get it to run on my application ... so I ended up using react-native-smart-splash-screen library instead ... I would really like to use react-native-splash-screen but I don't have the time to play around with it as I have to deliver the app on time ... so may be when I am free and will play around with it and troubleshoot the issue that I am having ... Thanks for your help guys

Base29 avatar Dec 07 '17 05:12 Base29

same problem here, when to try adb logcat I found error Can't convert to color:type=0x1

solve by: created file android/app/src/main/res/values/colors.xml and setting content <?xml version="1.0" encoding="utf-8"?> <resources> <color name="primary_dark">#660B0B0B</color> </resources>

now splash screen working well with react-native-navigation on android and ios

MainActivity.java

package com.mmakmur;
import android.os.Bundle; // here
import com.facebook.react.ReactActivity;
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);  // here
        super.onCreate(savedInstanceState);
    }
}

xabree avatar Dec 09 '17 10:12 xabree

@xabree that could be a solution. Can you turn this to a pull request, update the docs for example. Unless there's a better way to modify it on the code without creating the color xml.

kennethpdev avatar Dec 09 '17 10:12 kennethpdev

Wow ... Just saw my logcat and same error message... I think this will resolve the issue

Sent from Mobile Device

On Dec 9, 2017 3:33 PM, "xabree" [email protected] wrote:

same problem here, when to try adb logcat I found error Can't convert to color:type=0x1

solve by: created file android/app/src/main/res/values/colors.xml and setting content

name="primary_dark">#660B0B0B

now splash screen working well with react-native-navigation on android and ios

MainActivity.java

package com.mmakmur; import android.os.Bundle; // here import com.facebook.react.ReactActivity; 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);  // here
    super.onCreate(savedInstanceState);
}

}

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/crazycodeboy/react-native-splash-screen/issues/127#issuecomment-350447726, or mute the thread https://github.com/notifications/unsubscribe-auth/AE-qLAJxKUKF-HWIkXn6ea_mA2A7gj4xks5s-mHtgaJpZM4QjgxP .

Base29 avatar Dec 09 '17 14:12 Base29

thank you @xabree this solved my crash on launch. Please create a pull request so that this error can be solved long term ;)

tzig avatar Dec 21 '17 11:12 tzig

if i'am make device with emulator is not errror, but i'am make build apk and run with android real device error? somebody pleas help me?

aryejfa avatar Mar 23 '18 11:03 aryejfa