1

my flutter app was works fine on android but when I want to add ads using google admob I followed the instructions here here but after I added the all the requirements and when I run my app it gives my this error

Launching lib\main.dart on SM A515F in debug mode...
lib\main.dart:1

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\husam\.gradle\caches\transforms-3\41205c7bc612f206229dc6e7d7c5af46\transformed\play-services-ads-lite-19.7.0\AndroidManifest.xml:27:5-43:15: AAPT: error: unexpected element <queries> found in <manifest>.


* 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 2m 44s
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 firebase_admob...

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_admob-0.9.3+4\android\build.gradle' line: 22

* What went wrong:
A problem occurred evaluating root project 'firebase_admob'.
> Failed to apply plugin [id 'com.android.library']
   > Minimum supported Gradle version is 5.1.1. Current version is 4.10.2. If using the gradle wrapper, try editing the distributionUrl in C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_admob-0.9.3+4\android\gradle\wrapper\gradle-wrapper.properties to gradle-5.1.1-all.zip

* 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 30s
2

Exception: The plugin firebase_admob could not be built due to the issue above.

I tried to change the gradle version to 5.1.1 but the same error expect that will refer to other gradle distribution also I tried to run flutter clean and flutter pub cache repair I will share some parts of my code if it required also When I tried to add the admob plugin and the code required in my code I faced this error

E/flutter ( 1088): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method loadBannerAd on channel plugins.flutter.io/firebase_admob)
E/flutter ( 1088): #0      MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:156
E/flutter ( 1088): <asynchronous suspension>
E/flutter ( 1088): #1      _invokeBooleanMethod (package:firebase_admob/firebase_admob.dart:612:23)
E/flutter ( 1088): <asynchronous suspension>
E/flutter ( 1088):
E/flutter ( 1088): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method showAd on channel plugins.flutter.io/firebase_admob)
E/flutter ( 1088): #0      MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:156
E/flutter ( 1088): <asynchronous suspension>
E/flutter ( 1088): #1      _invokeBooleanMethod (package:firebase_admob/firebase_admob.dart:612:23)

and this's the result of the flutter doctor command

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.2, on Microsoft Windows [Version 10.0.19042.746], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.8.3)
[√] Android Studio (version 4.1.0)
[√] IntelliJ IDEA Community Edition (version 2020.3)
[√] VS Code (version 1.54.3)
[√] Connected device (3 available)

! Doctor found issues in 1 category.
Hussam F. Alkdary
  • 655
  • 1
  • 6
  • 21

1 Answers1

0

I solve the issue by deleting the android folder and then run the following command flutter create . because I found similar issue here and then I modified the android folder as it required by admob after that I test my app with ads and it works fine but it gives me some errors

Plugin project :firebase_core_web not found. Please update settings.gradle.

and the answer was by editing the setting.gradle file from this issue here like this

include ':app'

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
    pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}

plugins.each { name, path ->
    def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
    include ":$name"
    project(":$name").projectDir = pluginDirectory
}
Hussam F. Alkdary
  • 655
  • 1
  • 6
  • 21