gpt4 book ai didi

java - AAPT : error: style attribute 'android:attr/windowSplashScreenBackground' not found

转载 作者:行者123 更新时间:2023-12-05 05:56:42 28 4
gpt4 key购买 nike

我遇到了同样的错误,使用 Android Studio Canary。

它在 Gradle 4.2.1 和 Gradle 最新版本 7.1.0-alpha09 中返回相同的错误。 (即错误日志如下)

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)

此外,我已经更新:

  1. Android 12(S) 的 SDK 平台。
  2. Plus SDK Build Tools 已更新为 Android SDK Build-Tools 31

我必须在哪里/如何实现这些样式属性?我已将以下项目添加到 Styles.xml

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

最佳答案

很可能是我的 question 的副本

我猜你没有更改主题父主题

随着最新更新,Android 12 随附 SplashScreen API以确保从 Android 12 开始正确显示启动画面。

要访问它,您必须升级您的gradle 文件并将您的主题父 更改为Theme.SplashScreen .在你的 gradle 添加:

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'
...
}

创建一个单独的 style.xml对于启动画面

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

在 list 中设置主题 <application>

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

最后 MainActivity或您的启动 Activity 以加载启动画面,在 onCreate() 中设置此项之前setContentView()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

installSplashScreen()

setContentView(...)
}

关于java - AAPT : error: style attribute 'android:attr/windowSplashScreenBackground' not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69092015/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com