尝试构建发行版apk时出现以下提示 这是以下错误
任务':shared_preferences:verifyReleaseResources'的执行失败。 执行com.android.build.gradle.internal.tasks.Workers $ ActionFacade
时发生故障失败:构建失败,并出现异常。
出了什么问题: 配置根项目“ 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.
答案 0 :(得分:0)
由于AndroidX不兼容,似乎shared_preferences存在兼容性问题
您可以通过将项目迁移到android x
来解决此问题只需执行以下步骤
在Google Studio中打开Flutter项目(Android文件夹)
答案 1 :(得分:0)
尝试降级shared_preferences版本