Flutter构建错误:AAPT错误:找不到属性android:attr/fontVariationSettings的资源,ttcIndex。

3

目前我们在MS Appcenter上的Flutter构建失败,并出现以下日志:

* What went wrong:
Execution failed for task ':appcenter_analytics:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     /Users/runner/.gradle/caches/transforms-2/files-2.1/4bf813c12249ada6f409527e3c5fd194/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.

     /Users/runner/.gradle/caches/transforms-2/files-2.1/4bf813c12249ada6f409527e3c5fd194/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.

这个问题在本地无法重现,一切都正常。只有在Appcenter中构建时出现了问题。
大多数关于这个问题的答案似乎都与compileSdkVersion有关,而我们项目中的版本已经是28,我甚至尝试将其更改为29也没有用。我在Appcenter中设置了一个全新的流水线,但结果相同。我也更改了Flutter版本,但结果仍然相同。 在Appcenter中,Flutter doctor的输出如下:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.14.6 18G3020, locale en)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[!] Android Studio (not installed)
[!] Connected device
    ! No devices available

! Doctor found issues in 3 categories.
+ flutter build apk --release
Running "flutter pub get" in s...                                  11.6s
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform android-arm,android-arm64,android-x64
        Learn more on: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
        Learn more on:  https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'...                        
Gradle 5.6.4

谢谢!


尝试将compileSdkVersion更新为28对我有用。 - Mahmoud Abu Alheja
2个回答

2

我曾经遇到过类似的问题,与一个没有使用最新编译SDK版本的插件有关。您可以通过更改andoid/build.gradle文件并包含以下内容来强制执行:

subprojects {
    afterEvaluate { project ->
        if (project.name == "plugin_that_causes_the_issue") {
            android {
                compileSdkVersion 28
            }
        }
    }
}

0

我在构建Flutter应用时遇到了同样的错误。

  • 打开项目结构(文件 -> 项目结构)。
  • 然后在项目SDK中选择Android API 29平台。
  • 点击确定

如果问题没有解决,则在Android Studio中打开Android模块(工具 -> Flutter -> 在Android Studio中打开进行编辑)。并尝试从“构建”中构建apk。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接