【问题标题】:build flutter com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed构建颤振com.android.builder.internal.aapt.v2.Aapt2Exception:Android资源链接失败
【发布时间】:2020-04-06 12:32:04
【问题描述】:

昨天我把flutter升级到了最新版本(1.12.13+hotfix.5),在构建flutter apk的时候出现如下错误

* What went wrong:                                                                                                 
Execution failed for task ':sharesdk_plugin:verifyReleaseResources'.                                               
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
  /Users/binaryiv/Documents/projects/appProjects/huoli/app/build/sharesdk_plugin/intermediates/res/merged/release/values/values.xml:879: error: resource android:attr/fontVariationSettings not found.
  /Users/binaryiv/Documents/projects/appProjects/huoli/app/build/sharesdk_plugin/intermediates/res/merged/release/values/values.xml:880: error: resource android:attr/ttcIndex not found.
  error: failed linking references. 

我的 compileSdkVersion 和 targetSdkVersion 是 28,我可以通过删除 sharesdk_plugin 插件来构建它。有没有其他方法可以通过构建来配置和保留插件

【问题讨论】:

    标签: android flutter dart


    【解决方案1】:

    我在error: resource android:attr/fontVariationSettings not found找到最后一个答案可以解决我的sharedk_plugin问题添加代码:

    subprojects {
        afterEvaluate {project ->
            if (project.hasProperty("android")) {
                android {
                    compileSdkVersion 28
                    buildToolsVersion '29.0.2'
                }
            }
        }
    }
    

    在 android/build.gradle 中最后。 祝你好运。

    【讨论】:

    • 我能够通过对特定项目进行更改来解决这样的问题...if (project.name == "plugin_that_has_the_issue") { android { .... } }
    【解决方案2】:

    转到文件:

    ~/flutter/.pub-cache/hosted/pub.dartlang.org/sharesdk_plugin-1.2.1/android/build.gradle
    

    并将 all compileSdkVersion 更改为:

    compileSdkVersion 28
    

    ps: build.gradle 中可能有超过 1 个 compileSdkVersion。

    【讨论】:

      【解决方案3】:

      我也有同样的问题,但插件不同。 首先删除缓存,即无效缓存/重新启动,然后, 添加: gradle.properties 中的 android.enableAapt2=false。

      【讨论】:

        猜你喜欢
        • 2021-12-15
        • 2019-04-18
        • 2019-07-14
        • 1970-01-01
        • 2021-10-21
        • 2021-06-06
        • 1970-01-01
        相关资源
        最近更新 更多