skip to Main Content

I’ve got the very same error, using Android Studio Canary.

It returns the same error in Gradle 4.2.1 and Gradle latest version 7.1.0-alpha09. (i.e. error log is bellow)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
ERROR:/home/iuri/QonteoApps/biometricmax/node_modules/react-native-splash-screen/android/build/intermediates/packaged_res/release/values/values.xml:13:5-18:13: AAPT: error: style attribute 'android:attr/windowSplashScreenBackground' not found.
    
ERROR:/home/iuri/QonteoApps/biometricmax/node_modules/react-native-splash-screen/android/build/intermediates/packaged_res/release/values/values.xml:13:5-18:13: AAPT: error: style attribute 'android:attr/windowSplashScreenAnimatedIcon' not found.
    
ERROR:/home/iuri/.gradle/caches/transforms-3/de2ed04f8522efd4ca22835ece62dd33/transformed/core-splashscreen-1.0.0-alpha01/res/values-v31/values-v31.xml:3:5-9:13: AAPT: error: style attribute 'android:attr/windowSplashScreenAnimatedIcon' not found.
    
ERROR:/home/iuri/.gradle/caches/transforms-3/de2ed04f8522efd4ca22835ece62dd33/transformed/core-splashscreen-1.0.0-alpha01/res/values-v31/values-v31.xml:3:5-9:13: AAPT: error: style attribute 'android:attr/windowSplashScreenBackground' not found.
    
ERROR:/home/iuri/.gradle/caches/transforms-3/de2ed04f8522efd4ca22835ece62dd33/transformed/core-splashscreen-1.0.0-alpha01/res/values-v31/values-v31.xml:3:5-9:13: AAPT: error: style attribute 'android:attr/windowSplashScreenAnimationDuration' not found.

at com.android.builder.internal.aapt.v2.Aapt2Exception$Companion.create(Aapt2Exception.kt:45)
at com.android.builder.internal.aapt.v2.Aapt2Exception$Companion.create$default(Aapt2Exception.kt:39)

Furthermore, I’ve updated:

  1. SDK Platform to Android 12(S).
  2. Plus SDK Build Tools is updated to Android SDK Build-Tools 31

Where/How must I implement those style attributes?
I’ve added the following items to Styles.xml

    <item name="android:windowBackground">@drawable/splash</item>
    <item name="android:windowSplashScreenBackground">@drawable/splash</item>
    <item name="android:windowSplashScreenAnimatedIcon">@null</item>

2

Answers


  1. Chosen as BEST ANSWER

    I did change theme parent within AndroidManifest.xml.

    After a long time debugging and burning neurons, I switched to another react-native pluggin called bootsplash. https://www.reactnativeschool.com/simple-splash-launch-boot-screen-in-react-native-ios-and-android

    It seems react-native-splashscreen's core (i.e. latest version 3.2.0) has a bug within JAVA's native source code.

    Best wishes, I


  2. Most probably a duplicate of my question

    I guess you didn’t change the theme parent.

    With the latest update, Android 12 comes with SplashScreen API to ensure the splash screen displays correctly starting in Android 12.

    To access that you have to upgrade your gradle file and change your theme parent to Theme.SplashScreen. In your gradle add:

    android {
        //before syncing please make sure Android API 12 is installed in SDK manager
        compileSdkVersion 31 
        ...
    }
    dependencies {
        ...
        implementation 'androidx.core:core-splashscreen:1.0.0-alpha01'
        ...
    }
    

    Create a separate style.xml for the splash screen

    <resources>
        <style name="Theme.MySplashScreen" parent="Theme.SplashScreen"> 
            <item name="windowSplashScreenBackground">@color/black</item> <!-- If it's a @drawable make sure it's in .xml format-->
            <item name="windowSplashScreenAnimationDuration">1000</item>
            <item name="windowSplashScreenAnimatedIcon">@drawable/books_logo</item>
            <item name="postSplashScreenTheme">@style/Theme.Books</item> <!-- This will switch back to your given theme once the splash screen is gone-->
        </style>
    </resources>
    

    Set the theme in your manifest <application>

    <manifest>
       <application 
       ...
       android:theme="@style/Theme.MySplashScreen">
       ...
    

    Finally in MainActivity or your start activity to load the splash screen set this in onCreate() before setContentView()

    override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
    
            installSplashScreen()
    
            setContentView(...)
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search