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

Error on Android

Open IceNeoMax opened this issue 7 years ago • 21 comments

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) 

IceNeoMax avatar Mar 03 '17 06:03 IceNeoMax

Same here. RN 0.40

clucasalcantara avatar Mar 03 '17 12:03 clucasalcantara

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.

clucasalcantara avatar Mar 03 '17 12:03 clucasalcantara

Getting the same issue, commenting out SplashScreen.show(this); also prevents the crash for me.

liamfd avatar Mar 03 '17 16:03 liamfd

Same problem here with the line SplashScreen.show(this);

brunocascio avatar Mar 09 '17 12:03 brunocascio

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 avatar Mar 09 '17 13:03 brunocascio

@brunocascio it can't work for me ,I have to add it to function onResume.I think it is not a good Solution。

xxfreedom avatar Mar 15 '17 10:03 xxfreedom

@xxfreedom

Could you paste here the code of MainActivity.java and MainApplication.javafiles?

brunocascio avatar Mar 15 '17 13:03 brunocascio

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.

masteralb avatar Mar 28 '17 17:03 masteralb

@IceNeoMax open drawable/launch_screen_bitmap.xml then remove <item android:drawable="@color/splashBackground" /> then clean and build

daominhsangvn avatar Sep 01 '17 08:09 daominhsangvn

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"

aylabyuk avatar Oct 13 '17 05:10 aylabyuk

Same issue( RN 0.52 Android 7.1

asinel avatar Mar 21 '18 21:03 asinel

@asinel Did you check if the SplasScreen.show(this) is it in the right file (MainActivity.java instead of MainApplication.java)?

clucasalcantara avatar Mar 26 '18 19:03 clucasalcantara

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

awy1988 avatar Apr 26 '18 09:04 awy1988

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(),
      );
    }
}

FreddieOD avatar May 03 '18 12:05 FreddieOD

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

aaronshier avatar Aug 16 '18 21:08 aaronshier

That's because you don't have: image

Check the example, and copy file to your project

jsu93 avatar Sep 07 '18 05:09 jsu93

I have the same issue. I created an elaborated question on StackOverflow.

janhesters avatar Oct 11 '18 11:10 janhesters

`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) `

Biplovkumar avatar Mar 09 '19 16:03 Biplovkumar

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)

omprakashnitdgp avatar Mar 18 '20 12:03 omprakashnitdgp

I have faced the same issue occurs because I have created launch_screen.xml with a different namesplash.xml in the layout folder

vishaldhanotiya avatar Dec 09 '20 09:12 vishaldhanotiya

Had the same issue, followed this and fixed it https://github.com/crazycodeboy/react-native-splash-screen/issues/167#issuecomment-517971996

vasscher avatar Jun 01 '22 14:06 vasscher