离线打包失败 error style attribute android attr windowOptOutEdgeToEdgeEnforcement not found

离线打包失败 error style attribute android attr windowOptOutEdgeToEdgeEnforcement not found

操作步骤:

  • 升级至最新离线SDK Android-SDK@4.45.82353_20250106

预期结果:

  • 打包成功

实际结果:

Android resource linking failed  
io.xx.app-mergeReleaseResources-35:/values/values.xml:2466: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
io.xx.app-mergeReleaseResources-35:/values-v32/values-v32.xml:7: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
io.xx.app-mergeReleaseResources-35:/values/values.xml:5829: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
io.xx.app-mergeReleaseResources-35:/values/values.xml:5836: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
io.xx.app-mergeReleaseResources-35:/values/values.xml:5842: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
io.xx.app-mergeReleaseResources-35:/values/values.xml:6895: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
io.xx.app-mergeReleaseResources-35:/values/values.xml:7446: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
io.xx.app-mergeReleaseResources-35:/values/values.xml:9513: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
io.xx.app-mergeReleaseResources-35:/values/values.xml:9536: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
error: failed linking references.

bug描述:

  • Android Studio离线打包,使用离线SDK 4.08.82057_20240402,打包成功,
  • 后面升级至最新离线SDK Android-SDK@4.45.82353_20250106,打包失败,报错如下:
Android resource linking failed  
io.xx.app-mergeReleaseResources-35:/values/values.xml:2466: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
io.xx.app-mergeReleaseResources-35:/values-v32/values-v32.xml:7: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
io.xx.app-mergeReleaseResources-35:/values/values.xml:5829: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
io.xx.app-mergeReleaseResources-35:/values/values.xml:5836: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
io.xx.app-mergeReleaseResources-35:/values/values.xml:5842: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
io.xx.app-mergeReleaseResources-35:/values/values.xml:6895: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
io.xx.app-mergeReleaseResources-35:/values/values.xml:7446: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
io.xx.app-mergeReleaseResources-35:/values/values.xml:9513: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
io.xx.app-mergeReleaseResources-35:/values/values.xml:9536: error: style attribute 'android:attr/windowOptOutEdgeToEdgeEnforcement' not found.  
error: failed linking references.

项目信息:

信息
产品分类 uniapp/App
PC开发环境 Windows
PC版本号 19044.1618
手机系统 Android
手机系统版本 Android 14
手机厂商 OPPO
手机机型 一加8
页面类型 vue
Vue版本 vue3
打包方式 离线
项目创建方式 CLI
CLI版本号 3.0.0-4040520250104002

5 回复

其余代码、文件均未改动,仅仅是把最新版SDK拷贝过来,打包,然后就报错。退回旧版SDK打包正常


已解决 compileSdk = 35

4.45的版本,有问题。正常情况下,compileSdk = 34,应该也是可以编译通过的。现在,还有很多App是compileSdk = 34编译的。希望官方能够解决~

感谢,解决问题了。 真坑,官方每次升级,都得出幺蛾子,原来跑的好好的,升个级,跑不起来了,还好找到了这篇文章,不然又得折腾。。。 官方啥时候能让人省心。。。

这个错误是因为新版本SDK中使用了Android 13引入的windowOptOutEdgeToEdgeEnforcement属性,但你的编译环境可能没有使用足够新的Android SDK版本。

解决方案:

  1. 确保你使用的Android SDK版本至少是API 33(Android 13)或更高版本
  2. 在项目的build.gradle文件中修改compileSdkVersion为33或更高:
android {
    compileSdkVersion 33
    // 其他配置...
}
  1. 或者可以尝试在项目的styles.xml中添加以下属性定义:
<item name="android:windowOptOutEdgeToEdgeEnforcement">false</item>
回到顶部