You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级targetSdkVersion到32后Flutter安卓构建报错:找不到Theme.Design.NoActionBar

解决Flutter安卓targetSdkVersion升级到32后Theme.Design.NoActionBar找不到的问题

这个错误是因为Theme.Design.NoActionBar属于旧版Android Support库,而targetSdkVersion 32要求使用AndroidX生态,旧版Support库的资源已不再被兼容。以下是具体解决步骤:

  • 确认AndroidX配置
    检查android/gradle.properties文件,确保包含以下配置(若没有则添加):

    android.useAndroidX=true
    android.enableJetifier=true
    
  • 替换主题父类
    打开android/app/src/main/res/values/styles.xml,找到LaunchTheme的定义,将父主题从Theme.Design.NoActionBar替换为AndroidX兼容的主题,推荐使用Material Components主题:

    <style name="LaunchTheme" parent="Theme.MaterialComponents.NoActionBar">
        <!-- 保留你原有的样式属性 -->
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>
    

    若项目未使用Material Components,也可替换为AppCompat主题:Theme.AppCompat.NoActionBar

  • 添加Material Components依赖
    打开android/app/build.gradle,在dependencies块中添加Material Components库依赖(版本可根据需求调整):

    dependencies {
        // 其他依赖...
        implementation 'com.google.android.material:material:1.9.0'
    }
    
  • 清理重建项目
    执行以下命令清理缓存并重新构建:

    flutter clean
    flutter build apk
    

内容的提问来源于stack exchange,提问作者MoRmdn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 09:20:30