androidflutteryamlfirebase-admob

Why adding firebase_admob: ^0.11.0+1 in pubspec.yaml generats error when run (Flutter, Android)


I am trying to add ads using firebase and admob in my app but when i add firebase_admob: ^0.11.0+1 in pubspec.yaml and run project then it generats error as shown below: and without firebase_admob: ^0.11.0+1 package my app runs very well, i have also tried some other version of this package but none of them worked

Launching lib\main.dart on SM M307F in debug mode...
 lib\main.dart
Parameter format not correct -

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\Anil\.gradle\caches\transforms-2\files-2.1\6359b74b36ad352bbcae735fbbcd4399\play-services-ads-lite-19.6.0\AndroidManifest.xml:27:5-38: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 17s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin audioplayers...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'audioplayers'.
> 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 2s
Exception: The plugin audioplayers could not be built due to the issue above.
Exited (sigterm)

Packages i'm using:

dependencies:
  flutter:
    sdk: flutter

  torch_compat: ^1.0.2
  screen: ^0.0.5
  battery_info: ^1.0.7
  shake: ^0.1.0
  provider: ^4.3.3
  shared_preferences: ^0.5.12+4
  audioplayers: ^0.16.1
  vibration: ^1.7.3
  share: ^0.6.5+4
  flutter_email_sender: ^4.0.0
  firebase_admob: ^0.11.0+1

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.0


Solution

  • You need to update classpath in android/build.gradle

    from :

    classpath 'com.android.tools.build:gradle:3.5.0'
    

    to :

    classpath 'com.android.tools.build:gradle:3.5.4'
    

    also add https://pub.dev/packages/firebase_core to your pubspec.yaml