uni-app AAPT error: style attribute 'android:attr/forceDarkAllowed' not found.
uni-app AAPT error: style attribute ‘android:attr/forceDarkAllowed’ not found.
| 项目信息 | 值 |
|---|---|
| 产品分类 | uniapp/App |
| PC开发环境操作系统 | Windows |
| PC开发环境操作系统版本号 | 10 |
| HBuilderX类型 | 正式 |
| HBuilderX版本号 | 3.1.4 |
| 手机系统 | Android |
| 手机系统版本号 | Android 8.1 |
| 手机厂商 | 华为 |
| 手机机型 | 安卓 |
| 页面类型 | vue |
| 打包方式 | 云端 |
| 项目创建方式 | HBuilderX |
操作步骤:
离线打包
从2.7.14 升级到3.1.4 报错
AAPT: error: style attribute ‘android:attr/forceDarkAllowed’ not found.
```
<style name="DCloudTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:colorEdgeEffect">#333333</item>
<item name="android:windowBackground">@color/ime_background</item>
<item name="android:forceDarkAllowed">false</item>
</style>
<style name="TranslucentTheme" parent="@android:style/Theme.DeviceDefault.Light">
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:colorEdgeEffect">#333333</item>
<item name="android:windowBackground">@null</item>
<item name="android:forceDarkAllowed">false</item>
</style>
```
### 预期结果:
ok
### 实际结果:
爆炸
叫更新 compileSdkVersion 28 到 compileSdkVersion 29
呵呵呵呵呵呵
### bug描述:
离线打包
AAPT: error: style attribute 'android:attr/forceDarkAllowed' not found.
<style name="DCloudTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:colorEdgeEffect">#333333</item>
<item name="android:windowBackground">@color/ime_background</item>
<item name="android:forceDarkAllowed">false</item>
</style>
<style name="TranslucentTheme" parent="@android:style/Theme.DeviceDefault.Light">
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:colorEdgeEffect">#333333</item>
<item name="android:windowBackground">@null</item>
<item name="android:forceDarkAllowed">false</item>
</style>
更多关于uni-app AAPT error: style attribute 'android:attr/forceDarkAllowed' not found.的实战教程也可以访问 https://www.itying.com/category-93-b0.html
compileSdkVersion 29
minSdkVersion 21
targetSdkVersion 28
也没有问题,估计关键是compileSdkVersion为29
更多关于uni-app AAPT error: style attribute 'android:attr/forceDarkAllowed' not found.的实战教程也可以访问 https://www.itying.com/category-93-b0.html
配置都是ok的
更新 compileSdkVersion 28 到 compileSdkVersion 29
就没有这个报错 但是项目不支持29
Task :app:processDebugResources FAILED AGPBI: {“kind”:“error”,“text”:“Android resource linking failed”,“sources”:[{“file”:“C:\Users\wl.gradle\caches\transforms-2\files-2.1\2b31a6b5135f3ee2048c20b76de0d8a1\jetified-lib.5plus.base-release\res\values\values.xml”,“position”:{“startLine”:73,“startColumn”:4,“startOffset”:4833,“endLine”:78,“endColumn”:12,“endOffset”:5164}}],“original”:"C:\Users\wl.gradle\caches\transforms-2\files-2.1\2b31a6b5135f3ee2048c20b76de0d8a1\jetified-lib.5plus.base-release\res\values\values.xml:74:5-79:13: AAPT: error: style attribute ‘android:attr/forceDarkAllowed’ not found.\n ",“tool”:“AAPT”} AGPBI: {“kind”:“error”,“text”:“Android resource linking failed”,“sources”:[{“file”:“C:\Users\wl.gradle\caches\transforms-2\files-2.1\2b31a6b5135f3ee2048c20b76de0d8a1\jetified-lib.5plus.base-release\res\values\values.xml”,“position”:{“startLine”:116,“startColumn”:4,“startOffset”:7199,“endLine”:122,“endColumn”:12,“endOffset”:7587}}],“original”:"C:\Users\wl.gradle\caches\transforms-2\files-2.1\2b31a6b5135f3ee2048c20b76de0d8a1\jetified-lib.5plus.base-release\res\values\values.xml:117:5-123:13: AAPT: error: style attribute ‘android:attr/forceDarkAllowed’ not found.\n ",“tool”:“AAPT”}
Execution failed for task ‘:app:processDebugResources’.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
C:\Users\wl.gradle\caches\transforms-2\files-2.1\2b31a6b5135f3ee2048c20b76de0d8a1\jetified-lib.5plus.base-release\res\values\values.xml:74:5-79:13: AAPT: error: style attribute ‘android:attr/forceDarkAllowed’ not found.
解决了吗?大佬
硬性要求 compileSdkVersion更新到29。后续就会要求30了
。。。。。
不知道在哪里看到一条信息
build.gradle配置里面
compileSdkVersion 29
minSdkVersion 26
targetSdkVersion 26
就解决这个题了,目前的3.1.18可以支持到29的,最小26
我就是这么解决的
太多坑了
compileSdkVersion 32
minSdkVersion 29
targetSdkVersion 32
一直报这个问题,有没有解决的
这个错误是因为 android:forceDarkAllowed 属性在 Android 10(API 29)中才被引入,而你的项目当前使用的 compileSdkVersion 是 28。当你从 uni-app 2.7.14 升级到 3.1.4 时,新版本可能默认使用了更高版本的 Android 支持库,其中引用了该属性。
解决方案如下:
-
更新
compileSdkVersion到 29 或更高版本:在项目的build.gradle(Android 部分)中,将compileSdkVersion设置为 29 或更高。例如:android { compileSdkVersion 29 // 其他配置 } -
同步更新相关依赖:确保
targetSdkVersion和依赖库(如 AppCompat)与compileSdkVersion兼容。例如:android { compileSdkVersion 29 targetSdkVersion 29 }

