Search code examples
flutterflutter-dependenciesgoogle-mobile-ads

Build failed with an exception error Flutter with Google Ads


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\afran.gradle\caches\transforms-2\files-2.1\64c98a67cb9daf6485fbefd78c4aebac\play-services-ads-lite-19.7.0\AndroidManifest.xml:27:5-43:15: AAPT: error: unexpected element found in .

  • 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 5s 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 cloud_firestore... Running Gradle task 'assembleAarRelease'... Exception: The plugin cloud_firestore could not be built due to the issue above. These are the Dependencies iam using

dependencies:
  flutter:
    sdk: flutter
  google_mobile_ads: ^0.12.0
  flutter_spinkit: ^5.0.0
  #geolocation: ^1.1.2
  cloud_firestore: ^1.0.3
  firebase_storage: ^8.0.0
  permission_handler: ^6.0.1+1
  firebase_core: ^1.0.1
  url_launcher: ^6.0.2
  firebase_auth: ^1.0.1
  provider: ^5.0.0
  google_fonts: ^2.0.0
  shared_preferences: ^2.0.4
  connectivity: ^3.0.2
  mailer: ^4.0.0
  firebase_messaging: ^9.1.0
  flutter_local_notifications: ^5.0.0+1

My Bulid.gradle

android {
    compileSdkVersion 30

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.afran.form_app"
        minSdkVersion 22
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName

    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

Solution

  • I just found out the solution, queries is a new manifest element and require to use a new gralde android plugin.

    so change to this version in build.gradle, this worked for me

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

    Also change gradle-wrapper version to 6.5 as it is required by 4.1.0 plugin