flutter - 构建失败可能是由于插件中的 AndroidX 不兼容。该工具即将尝试使用Jetifier解决不兼容问题
问题描述
Α将 google_mobile_ads 插件添加到我的颤振项目后,当我尝试运行我的应用程序时出现以下错误。
Launching lib\main.dart on Android SDK built for x86 in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
C:\Users\Simon\.gradle\caches\transforms-2\files-2.1\fb3ac92d6ea8a3919475bb567eb91a20\core-1.7.0-alpha02\res\values\values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar 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 1m 18s
The build failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetifier to solve the incompatibility.
Building plugin audioplayers...
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\flutter\.pub-cache\hosted\pub.dartlang.org\audioplayers-0.19.0\android\build.gradle' line: 25
* What went wrong:
A problem occurred evaluating root project 'audioplayers'.
> Failed to apply plugin [id 'kotlin-android']
> The current Gradle version 4.10.2 is not compatible with the Kotlin Gradle plugin. Please use Gradle 5.3 or newer, or the previous version of the Kotlin plugin.
* 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 3s
Exception: The plugin audioplayers could not be built due to the issue above.
Exited (sigterm)
奇怪的是,当我回到我没有添加 google_mobile_ads 的旧版本的应用程序时,我仍然收到类似的错误。
我尝试将 build.gradle 中的类路径“com.android.tools.build:gradle:3.5.0”的版本从 3.5.0 更改为 4.0.1,但我仍然遇到相同的错误。
任何帮助深表感谢。谢谢
解决方案
我做了三件事,其中一些解决了这个问题。
- 安装最新版本的音频播放器插件。
- 使用 Android Studio 和 Build -> Rebuild Project 打开 android 文件夹
- 在 Android Studio 中,将 Gradle 从 3.xx 更新到 5.xx
推荐阅读
- gradle - “此处不得使用插件 {} 块。如果您需要强制应用插件”究竟是什么?
- reactjs - 在 React 中为页脚创建超链接
- asp.net-core - 在 Blazor WASM 中获取原始 oauth 令牌?
- java - JAVA parse properties file with similar numbered keys
- reactjs - 在 React 中只渲染一次函数
- python - 使用 pandas,如何检查列中是否存在特定序列?
- c - 输出是什么,为什么函数中的指针不会影响代码?
- python - 如何在熊猫数据框滚动窗口中添加一个步骤
- css - 是否可以使用 CSS 在移动设备上将图像从纵向更改为横向?
- owl - 如何在 Protegé 中加入来自 2 个不同本体的等效类?