首页 > 解决方案 > 构建失败可能是由于插件中的 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,但我仍然遇到相同的错误。

任何帮助深表感谢。谢谢

标签: flutteradmobflutter-dependenciesflutter-plugingooglemobileads

解决方案


我做了三件事,其中一些解决了这个问题。

  1. 安装最新版本的音频播放器插件。
  2. 使用 Android Studio 和 Build -> Rebuild Project 打开 android 文件夹
  3. 在 Android Studio 中,将 Gradle 从 3.xx 更新到 5.xx

推荐阅读