zoontek / react-native-bootsplash

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

[android] Resources$NotFoundException: Drawable :drawable/compat_splash_screen with resource ID #493

Closed Aure77 closed 1 year ago

Aure77 commented 1 year ago

Bug summary

Running app without  androidx.core:core-splashscreen (added in v4) in v5 should crash due to appcompat issue when bitmap source when brand image is not provided.

Caused by: android.content.res.Resources$NotFoundException: Drawable my.app:drawable/compat_splash_screen with resource ID #0x7f080077
                                                                                                    Caused by: java.lang.RuntimeException: org.xmlpull.v1.XmlPullParserException: <internal>: <bitmap> requires a valid 'src' attribute
                                                                                                    Caused by: org.xmlpull.v1.XmlPullParserException: <internal>: <bitmap> requires a valid 'src' attribute
                                                                                                        at android.graphics.drawable.BitmapDrawable.updateStateFromTypedArray(BitmapDrawable.java:854)
                                                                                                        at android.graphics.drawable.BitmapDrawable.applyTheme(BitmapDrawable.java:916)
                                                                                                        at android.graphics.drawable.LayerDrawable.applyTheme(LayerDrawable.java:236)
                                                                                                        at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:684)
                                                                                                        at android.content.res.Resources.loadDrawable(Resources.java:1002)
                                                                                                        at android.content.res.Resources.getDrawableForDensity(Resources.java:992)
                                                                                                        at android.content.res.Resources.getDrawable(Resources.java:931)
                                                                                                        at android.content.Context.getDrawable(Context.java:810)
                                                                                                        at androidx.core.content.ContextCompat$Api21Impl.getDrawable(ContextCompat.java:1012)

Which appcompat & appcompat-resources version are recommended with this lib ?

Library version

5.0.2

Environment info

System:
    OS: macOS 13.6
    CPU: (8) arm64 Apple M1
    Memory: 98.52 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.0 - /var/folders/8k/qyy417_57vb1nd1p1985ggdr0000gp/T/yarn--1696431071503-0.8222933811281603/node
    Yarn: 1.22.19 - /var/folders/8k/qyy417_57vb1nd1p1985ggdr0000gp/T/yarn--1696431071503-0.8222933811281603/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v18.18.0/bin/npm
    Watchman: 2023.09.25.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.12.1 - /Users/me/.gem/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 23.0, iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: 15.0/15A240d - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.20.1 - /opt/homebrew/opt/openjdk@11/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: ^0.71.0 => 0.71.13 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

  1. don't use bootSplashBrand in styles.xml
  2. minSdkVersion = 21, target = 33
  3. Run on Android 13

Reproducible sample code

styles.xml:

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
    </style>

    <!-- BootTheme should inherit from Theme.BootSplash or Theme.BootSplash.EdgeToEdge -->
    <style name="BootSplashTheme" parent="Theme.BootSplash">
        <item name="bootSplashBackground">@color/bootsplash_background</item>
        <item name="bootSplashLogo">@drawable/bootsplash</item>
        <!-- no bootSplashBrand here -->
        <item name="postBootSplashTheme">@style/AppTheme</item>
    </style>
zoontek commented 1 year ago

Which appcompat & appcompat-resources version are recommended with this lib ?

Nothing more than what's shipped with react-native.

Looks like a config or cache issue. Could you run the example app? There's no bootSplashBrand there too (and it works correctly)

Aure77 commented 1 year ago

My bad, I use wrong drawable asset in theme 🤒