android – Flutter – The plugin firebase_core could not be built-ThrowExceptions

Exception or error:

I am building my flutter release build for Android and firebase_core plugin is crashing during build. Previously everything used to work fine but I made a fresh install of windows, Android studio and downloaded latest flutter sdk. Now this error with firebase_core plugin is showing up. Here are my logs

D:\AndroidProjets\my_app>flutter build apk --split-per-abi
Running Gradle task 'assembleRelease'...
Note: D:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-6.0.9\android\src\main\java\io\flutter\plugins\firebasemessaging\FirebaseMessagingPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
D:\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences-0.5.6+2\android\src\main\java\io\flutter\plugins\sharedpreferences\SharedPreferencesPlugin.java:25: warning: [deprecation] getFlutterEngine() in FlutterPluginBinding h
as been deprecated
    setupChannel(binding.getFlutterEngine().getDartExecutor(), binding.getApplicationContext());
                        ^
1 warning
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Removed unused resources: Binary resource data reduced from 658KB to 635KB: Removed 3%
Removed unused resources: Binary resource data reduced from 658KB to 635KB: Removed 3%
Removed unused resources: Binary resource data reduced from 658KB to 635KB: Removed 3%

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':clipboard_manager:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     C:\Users\.gradle\caches\transforms-2\files-2.1\c5476b279721c45ae2c1305903c71386\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.

     C:\Users\.gradle\caches\transforms-2\files-2.1\c5476b279721c45ae2c1305903c71386\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex 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 4m 3s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                     244.7s (!)
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 admob_flutter...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done                   22.1s
√ Built build\app\outputs\repo.
Building plugin clipboard_manager...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done                   20.3s
√ Built build\app\outputs\repo.
Building plugin firebase_analytics...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done                   22.5s
√ Built build\app\outputs\repo.
Building plugin firebase_core...
The plugin firebase_core could not be built due to the issue above.
Running Gradle task 'assembleAarRelease'... 

And for the build.gradle

android {
    compileSdkVersion 29

    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 ""
        minSdkVersion 19
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
            v1SigningEnabled true
            v2SigningEnabled true
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release

            minifyEnabled true
            useProguard true
            shrinkResources true

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }

    aaptOptions {
        cruncherEnabled = false
    }
}

And finally my pubspec.yaml dependencies

cupertino_icons: ^0.1.3
  shared_preferences: ^0.5.6+2
  get_it: ^3.1.0
  http: ^0.12.0+4
  url_launcher: ^5.4.2
  flutter_staggered_animations: ^0.1.2
  cached_network_image: ^2.0.0
  intl: ^0.16.1
  clipboard_manager: ^0.0.4
  flutter_svg: ^0.17.1
  photo_view: ^0.9.2
  rxdart: ^0.23.1
  firebase_core: ^0.4.4
  firebase_analytics: ^5.0.11
  firebase_crashlytics: ^0.1.3
  firebase_messaging: ^6.0.9
  flutter_local_notifications: ^1.1.6
  admob_flutter: ^0.3.4
  auto_direction: ^0.0.4+1
  rate_my_app: ^0.6.0
  flutter_rating_bar: ^3.0.1+1
  flutter_linkify: ^3.1.0
How to solve:

I think changing the SharedPreference version will solve this issue, use shared_preferences: ^0.5.6+1

###

I resolved this issue by updating the build.gradle of clipboard_manager from compileSdkVersion 27 to 28 and then everything worked fine. the following helped me.

https://github.com/flutter/flutter/issues/44760

Leave a Reply

Your email address will not be published. Required fields are marked *