Hey After adding [facebook_audience_network][1]

[1]: https://pub.dev/packages/facebook_audience_network this plugin i try to run my app showing this error

PS F:\flutter_project\appname> flutter run
Running "flutter pub get" in appname...                        1,991ms
Using hardware rendering with device AOSP on IA Emulator. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
[com.facebook.android:audience-network-sdk:6.5.0] C:\Users\Muhammad Anas\.gradle\caches\transforms-2\files-2.1\65563cf69e171fcf6c6002590b159b4f\audience-network-sdk-6.5.0\AndroidManifest.xml:12:9-55 Error:
        Missing 'package' key attribute on element package at [com.facebook.android:audience-network-sdk:6.5.0] AndroidManifest.xml:12:9-55
[com.facebook.android:audience-network-sdk:6.5.0] C:\Users\Muhammad Anas\.gradle\caches\transforms-2\files-2.1\65563cf69e171fcf6c6002590b159b4f\audience-network-sdk-6.5.0\AndroidManifest.xml Error:
        Validation failed, exiting

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs

* 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 42s
Running Gradle task 'assembleDebug'...                                  
Running Gradle task 'assembleDebug'... Done                        43.8s
Exception: Gradle task assembleDebug failed with exit code 1

i also try Flutter Upgrade Response is:

Flutter is already up to date on channel stable

Flutter 2.2.0 • channel stable • https://github.com/flutter/flutter.git

Framework • revision b22742018b (12 days ago) • 2021-05-14 19:12:57 -0700

Engine • revision a9d88a4d18

Tools • Dart 2.13.0


Solution 1: Ganeshprasad Shenoy

Upgrade your Gradle Plugin. You can upgrade the version in your project-level build.gradle file:

buildscript {

    repositories {
        google()
        jcenter()
    }

    dependencies {
        // classpath 'com.android.tools.build:gradle:4.0.0'
        classpath 'com.android.tools.build:gradle:4.0.1'
    }
}

You can read about this error here


Solution 2: Ottoman Coder

I already encounter this issue whenever I try to use Facebook Ads in my Flutter App.

Try This:

android/build.gradle

add this line

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

Your code should look like this

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.4'  // Add Here
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

After this goto android\gradle\wrapper\gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

Just replace your distributionUrl and boom. Your Problem Will solve. if you're still facing this then let me


Solution 3: Soto-kun

I have upgraded my gradle, run flutter doctor that found no issue. But i am still getting the error.

The plugins facebook_audience_network, flutter_statusbarcolor_ns, flutter_webview_plugin, notification_permissions, onesignal_flutter, sms_autofill use a deprecated version of the Android embedding.