【发布时间】:2020-02-06 12:56:45
【问题描述】:
我正在尝试用颤振构建 apk。但每次我运行flutter build apk 或flutter build apk --release 时,构建总是失败,并出现这样的异常。
Running Gradle task 'assembleRelease'...
Removed unused resources: Binary resource data reduced from 44KB to 35KB: Removed 20%
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':webview_flutter:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
C:\Users\naonv\.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\naonv\.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 5m 12s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 315.2s (!)
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
✏️ Creating `android\settings_aar.gradle`... 178ms
√ `android\settings_aar.gradle` created successfully.
Building plugin webview_flutter...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 37.6s
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
WARNING: The option setting 'android.enableR8=true' is experimental and unsupported.
The current default is 'false'
Consider disabling R8 by removing 'android.enableR8=true' from your gradle.properties before publishing your app.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'webview_flutter'.
> 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 36s
The plugin webview_flutter could not be built due to the issue above.
这也发生在颤振示例应用程序中,也许我的设置有问题,但我不知道我需要编辑哪个,有人知道如何解决这个问题吗?
【问题讨论】:
-
Consider disabling R8 by removing 'android.enableR8=true' from your gradle.properties before publishing your app. -
我删除了该代码,但仍然出现同样的错误
-
单独打开你的安卓模块。等待 gradle 配置完成。现在您会看到所有插件的列表。打开flutter webview_flutter的gradl并将其目标sdk更改为28。它可能小于或等于27。
-
我已经使用 sdk 28,我尝试迁移到 androidX 但仍然遇到同样的错误,可能是因为 webview_plugin。 Flutter 有 2 个 webview 插件,我选择了这个插件