zoontek / react-native-bootsplash

🚀 Show a splash screen during app startup. Hide it when you are ready.
MIT License
3.75k stars 259 forks source link

Android app crashes after splash screen #380

Closed durgeshpgs closed 2 years ago

durgeshpgs commented 2 years ago

Bug summary

I am getting the following errors

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: android.view.InflateException: Binary XML file line #28 in com.myreactapp:layout/splash_screen_view: Failed to resolve attribute at index 0: TypedValue{t=0x2/d=0x7f030208 a=-1}
     Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 0: TypedValue{t=0x2/d=0x7f030208 a=-1}
        at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:826)
        at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:8231)
        at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:8429)
        at android.widget.FrameLayout$LayoutParams.<init>(FrameLayout.java:452)

Library version

4.3.0

Environment info

System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
    Memory: 8.66 GB / 15.87 GB
  Binaries:
    Node: 14.17.4 - C:\Program Files\nodejs\node.EXE
    Yarn: Not Found
    npm: 6.14.14 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK:
      API Levels: 27, 28, 29, 30, 31, 32
      Build Tools: 29.0.2, 30.0.2, 31.0.0, 32.0.0, 32.1.0
      System Images: android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom, android-31 | Google Play Intel x86 Atom_64, android-32 | Google Play Intel x86 Atom_64
      Android NDK: Not Found
    Windows SDK: Not Found
  IDEs:
    Android Studio: AI-212.5712.43.2112.8609683
    Visual Studio: 16.11.32002.261 (Visual Studio Community 2019), 17.1.32319.34 (Visual Studio Community 2022)
  Languages:
    Java: 11.0.15
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2
    react-native: 0.68.2 => 0.68.2
    react-native-windows: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

I follow the installation instructions and it's working fine with ios but giving error in android

Reproducible sample code

styles.xml

<resources>
  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:textColor">@android:color/black</item>
    <item name="android:editTextStyle">@style/ResetEditText</item>
    <item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
  </style>
  <style name="ResetEditText" parent="@android:style/Widget.EditText">
    <item name="android:padding">0dp</item>
    <item name="android:textColorHint">#c8c8c8</item>
    <item name="android:textColor">@android:color/black</item>
  </style>
  <style name="Theme.App.SplashScreen" parent="AppTheme">
    <item name="android:windowBackground">@drawable/splashscreen</item>
  </style>
  <style name="BootTheme" parent="Theme.SplashScreen">
    <item name="windowSplashScreenBackground">@color/bootsplash_background</item>
    <item name="windowSplashScreenAnimatedIcon">@mipmap/bootsplash_logo</item>
    <item name="postSplashScreenTheme">@style/AppTheme</item>
  </style>
</resources>

MainActivity.Java

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.zoontek.rnbootsplash.RNBootSplash; // for splash screen

import expo.modules.ReactActivityDelegateWrapper;

public class MainActivity extends ReactActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // Set the theme to AppTheme BEFORE onCreate to support 
    // coloring the background, status bar, and navigation bar.
    // This is required for expo-splash-screen.
    setTheme(R.style.AppTheme);
    RNBootSplash.init(this);
    super.onCreate(null);
  }

AndroidManifest.xml
zoontek commented 2 years ago

Something else is trying to load a file that does not seems to exists (or, if it exists, delete it):

Caused by: android.view.InflateException: Binary XML file line #28 in com.myreactapp:layout/splash_screen_view: Failed to resolve attribute at index 0

Not related to this library, I'm closing this.

saczx commented 2 years ago

@durgeshpgs How did you fix it ? Same error here

durgeshpgs commented 2 years ago

@saczx The issue with expo-splash-screen module which conflict with react native bootsplash. I have removed it's references from code and work well with android. You can find details here

https://stackoverflow.com/questions/73319284/react-native-app-crashes-after-splash-screen

saczx commented 2 years ago

Thanks dude, I was able to resolve this reinstalling / setting and upgrading the lib again @durgeshpgs