flutteradmobflutter-dependenciesflutter-plugingoogle-mobile-ads

The build failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetifier to solve the incompatibility


Αfter adding the google_mobile_ads plugin to my flutter project, I get the following error when I try to run my app.

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)

The weird thing is that when I go back to older versions of my app where I have not added google_mobile_ads, I still get a similar error.

I have tried changing the version of classpath 'com.android.tools.build:gradle:3.5.0' in build.gradle from 3.5.0 to 4.0.1 and I still get the same error.

Any help is much appreciated. Thanks


Solution

  • I did three things, some of which solved the issue.

    1. Install latest version of audioplayers plugin.
    2. Open the android folder with Android Studio and Build -> Rebuild Project
    3. From Android studio, update Gradle from 3.x.x to 5.x.x