react-native-splash-screen
react-native-splash-screen copied to clipboard
Error on Android
i got this message after build and i got message that "Unforturnately, App has stopped"
03-03 12:01:27.800 3084-3084/com.thesis E/AndroidRuntime: FATAL EXCEPTION: main Process: com.thesis, PID: 3084 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thesis/com.thesis.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f04002a type #0x1 is not valid at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f04002a type #0x1 is not valid at android.content.res.Resources.loadXmlResourceParser(Resources.java:2779) at android.content.res.Resources.getLayout(Resources.java:1165) at android.view.LayoutInflater.inflate(LayoutInflater.java:421) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) at android.app.Dialog.setContentView(Dialog.java:512) at com.cboy.rn.splashscreen.SplashScreen$1.run(SplashScreen.java:30) at android.app.Activity.runOnUiThread(Activity.java:5511) at com.cboy.rn.splashscreen.SplashScreen.show(SplashScreen.java:24) at com.thesis.MainActivity.onCreate(MainActivity.java:19) at android.app.Activity.performCreate(Activity.java:6237) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Same here. RN 0.40
Here the problem seems to be on the react-native-splash-screen module. I've commented the line: SplashScreen.show(this);
in the MainApplication and the app starts.
I'll check the module later to see if I can send a PR.
Getting the same issue, commenting out SplashScreen.show(this);
also prevents the crash for me.
Same problem here with the line SplashScreen.show(this);
Is a little bit confusing the name conventions, but well...
@clucasalcantara @liamfd
You need to add the line SplashScreen.show(this);
inside of MainActivity.java file instead of MainApplication.java.
This is my code:
MainActivity.java
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 "fbtmobile";
}
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this); // here
super.onCreate(savedInstanceState);
}
}
@brunocascio it can't work for me ,I have to add it to function onResume.I think it is not a good Solution。
@xxfreedom
Could you paste here the code of MainActivity.java
and MainApplication.java
files?
Same issue here, reason: wrong name for layout folder in res, the right name is: "layout" not "layouts".
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="@drawable/launch_screen">
</LinearLayout>
MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this); // here
super.onCreate(savedInstanceState);
}
MainApplication.java
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new SplashScreenReactPackage()
);
}
Hope this helps.
@IceNeoMax open drawable/launch_screen_bitmap.xml
then remove <item android:drawable="@color/splashBackground" />
then clean and build
This error happens to me since I mistakenly created the "layout" folder outside "res".. make sure you have the correct folder structure. "app/src/main/res/layout"
Same issue( RN 0.52 Android 7.1
@asinel Did you check if the SplasScreen.show(this)
is it in the right file (MainActivity.java instead of MainApplication.java)?
I met the similar issue, the reason is I wrote a wrong file name: lauch_screen.xml , after correct it to : launch_screen.xml,everything goes well
Same issue here RN 55 Android 6.0
public class MainActivity extends ReactActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this);
super.onCreate(savedInstanceState);
}
...
}
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 SplashScreenReactPackage(),
);
}
}
This fixed it for me, I simply forgot to follow the steps for installing the png in the right folders with all the correct xml data:
Unable to start activity ComponentInfo
I had to do what is described in this step:
https://github.com/crazycodeboy/react-native-splash-screen#getting-started
That's because you don't have:
Check the example, and copy file to your project
I have the same issue. I created an elaborated question on StackOverflow.
`Same issue
03-09 22:14:38.384 28230-28230/com.base_proj2 E/AndroidRuntime: FATAL EXCEPTION: main Process: com.base_proj2, PID: 28230 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.base_proj2/com.base_proj2.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f09001e type #0x1 is not valid at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2342) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2404) at android.app.ActivityThread.access$900(ActivityThread.java:154) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1315) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5296) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707) Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f09001e type #0x1 is not valid at android.content.res.Resources.loadXmlResourceParser(Resources.java:2754) at android.content.res.Resources.getLayout(Resources.java:1129) at android.view.LayoutInflater.inflate(LayoutInflater.java:416) at android.view.LayoutInflater.inflate(LayoutInflater.java:365) at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:378) at android.app.Dialog.setContentView(Dialog.java:490) at org.devio.rn.splashscreen.SplashScreen$1.run(SplashScreen.java:32) at android.app.Activity.runOnUiThread(Activity.java:5396) at org.devio.rn.splashscreen.SplashScreen.show(SplashScreen.java:27) at org.devio.rn.splashscreen.SplashScreen.show(SplashScreen.java:49) at com.base_proj2.MainActivity.onCreate(MainActivity.java:17) at android.app.Activity.performCreate(Activity.java:6093) `
I am also getting same error
RN version : 0.61
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.love/com.love.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f0d0036 type #0x1 is not valid at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
I have faced the same issue occurs because I have created launch_screen.xml
with a different namesplash.xml
in the layout folder
Had the same issue, followed this and fixed it https://github.com/crazycodeboy/react-native-splash-screen/issues/167#issuecomment-517971996