Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on Android #37

Open
IceNeoMax opened this issue Mar 3, 2017 · 21 comments
Open

Error on Android #37

IceNeoMax opened this issue Mar 3, 2017 · 21 comments

Comments

@IceNeoMax
Copy link

IceNeoMax commented Mar 3, 2017

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 IceNeoMax changed the title Error Error on Android Mar 3, 2017
@clucasalcantara
Copy link

Same here. RN 0.40

@clucasalcantara
Copy link

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.

@liamfd
Copy link

liamfd commented Mar 3, 2017

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

@brunocascio
Copy link

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

@brunocascio
Copy link

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

@xxfreedom
Copy link

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

@brunocascio
Copy link

@xxfreedom

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

@masteralb
Copy link

masteralb commented Mar 28, 2017

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.

@daominhsangvn
Copy link

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

@aylabyuk
Copy link

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"

@asinel
Copy link

asinel commented Mar 21, 2018

Same issue(
RN 0.52
Android 7.1

@clucasalcantara
Copy link

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

@awy1988
Copy link

awy1988 commented Apr 26, 2018

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

@FreddieOD
Copy link

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

@aaronshier
Copy link

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

@jsu93
Copy link

jsu93 commented Sep 7, 2018

That's because you don't have:
image

Check the example, and copy file to your project

@janhesters
Copy link

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

@Biplovkumar
Copy link

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

@omprakashnitdgp
Copy link

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)

@vishaldhanotiya
Copy link

vishaldhanotiya commented Dec 9, 2020

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

@vasscher
Copy link

vasscher commented Jun 1, 2022

Had the same issue, followed this and fixed it #167 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests