发布构建失败颤动

Posted

技术标签:

【中文标题】发布构建失败颤动【英文标题】:Release build failed flutter 【发布时间】:2020-05-14 00:23:03 【问题描述】:

我在尝试构建发布 apk 时收到以下信息 这是以下错误

任务“:shared_preferences:verifyReleaseResources”执行失败。 执行 com.android.build.gradle.internal.tasks.Workers$ActionFacade 时发生故障

FAILURE:构建失败并出现异常。

出了什么问题: 配置根项目“android_intent”时出现问题。

未找到 SDK 位置。使用 local.properties 文件中的 sdk.dir 或使用 ANDROID_HOME 环境变量定义位置。

    flutter build apk --release
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

FAILURE: Build failed with an exception.

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

     C:\Users\msubrata\.gradle\caches\transforms-2\files-2.1\0a271e99b6771ad4a84318244d532fb7\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                       7.7s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin android_intent...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done                    1.2s


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android_intent'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s


The plugin android_intent could not be built due to the issue above.

【问题讨论】:

【参考方案1】:

由于 AndroidX 不兼容,shared_preferences 似乎存在兼容性问题

您可以通过将项目迁移到 android x 来解决此问题

只需执行以下步骤

在 Android Studio 中打开 Flutter 项目(Android 文件夹)

    点击重构 点击迁移到 AndroidX 等待进程然后点击DoRefactor(会出现在Android Studio底部工具栏)

【讨论】:

【参考方案2】:

尝试降级 shared_preferences 版本

【讨论】:

以上是关于发布构建失败颤动的主要内容,如果未能解决你的问题,请参考以下文章

构建失败并出现异常 - 颤动

颤动的firebase错误“失败:构建失败并出现异常”

构建失败并出现异常。颤动的Gradle问题

升级firebase核心后颤动Ios构建失败

颤动的iOS构建失败(ld:找不到-lPods-Runner的库)

在更改了我颤动的 android 图标后,这发生了