0

Trying to integrate Firebase Cloud messaging in my flutter app and I only receive the Exit Code 1 error when I try running my app specifically using the android emulator. If I take out Cloud messaging, it works just fine. iOS simulator works just fine with or without cloud messaging.

This stack answer didn't work: Firebase Cloud Functions emulator throws "exited with code: 1" error

I've tried different versions and ranges of the Firebase Messaging Plugin from here: https://pub.dev/packages/firebase_messaging/versions.

I've tried so many different things from adding

I followed steps from different sources (including the official documentation) in which they all basically said the same thing:

add:


<action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />

to my Android manifest

add:

apply plugin: 'com.google.gms.google-services'

to the bottom of the app level build gradle

and my project level build gradle dependencies look like this:

dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        classpath 'com.google.gms:google-services:4.2.0'
    }

My exact console looks like this:

Launching lib/extras/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Finished with error: Gradle task assembleDebug failed with exit code 1

I really like the analytics and ease of sending messages Firebase has to offer so ideally I would want to fix this issue. If that can't happen, are there any alternatives to push custom notifications that's similar to FCM? Can Google Play and/or iOS StoreKit do this? I've never submitted an app to the app store yet and only recently bought my developer account from Apple.

TNasty
  • 105
  • 7
  • Tried cleaning, restarting android studio, my iMac too.. – TNasty Aug 03 '19 at 01:54
  • And just another note, Firebase is already integrated with my app and works just fine with Firebase auth – TNasty Aug 03 '19 at 02:01
  • Did you manage AndroidX compatibility? – iPatel Aug 03 '19 at 03:34
  • Yeah I migrated to AndroidX in Android Studios Refactor Menu > Refactor/Migrate to AndroidX – TNasty Aug 03 '19 at 03:39
  • So I tried a clone of Firebase Cloud messaging: https://pub.dev/packages/firebase_messagings and used https://fireship.io/lessons/flutter-push-notifications-fcm-guide/. No errors with the code however now my app doesn't load and has this error: Could not update files on device: HttpException: Connection closed before full header was received, uri = http://127.0.0.1:65383/SiZVFRRVeNA=/ – TNasty Aug 03 '19 at 03:42
  • Ok lets do one thing, You already did but follow these steps. 1) delete your app from device and simulator 2) run - flutter doctor and then Flutter Clean 3) flutter packages pub cache clean 4) Invalidate caches/restart Android studio. – iPatel Aug 03 '19 at 03:45
  • I followed the steps in the exact order but still no luck :/ – TNasty Aug 03 '19 at 03:58
  • Check google play service on emulator – Pankaj Bansal Aug 03 '19 at 10:32
  • Thanks for ur help guys but still no luck. After creating a fresh project and importing firebase messaging and core, I get this error: The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art ifact with the issue. -- Project 'app' depends on project 'firebase_messaging' which depends onto com.google.firebase:firebase-messaging@18.0. 0 -- Project 'app' depends onto com.google.firebase:firebase-core@17.0.0 -- Project 'app' depends on project 'firebase_core' which depends onto com.google.firebase:firebase-core@16.0.9 – TNasty Aug 03 '19 at 16:41
  • I pray no one else goes through what I've been through but if you do here's how you fix it: At the very bottom of ur app level build.gradle file (below apply plugin: 'com.google.gms.google-services') add (com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true). If that doesnt work. Create a new flutter app from scratch, drag and drop the Google services JSON file into your android > app directory (Things dont work for some reason if I directly download it to there), then add the disable version check line from above & that oughta do it. Thanks everyone for ur help – TNasty Aug 04 '19 at 17:59
  • oh AND in your app level build.gradle file defaultConfig, add (multiDexEnabled true)! – TNasty Aug 04 '19 at 18:57
  • Last tip: make sure your main.dart file is in the root of your lib folder (i had mine in another folder within lib). Rookie mistake for me so don't let it happen to you – TNasty Aug 04 '19 at 19:06

0 Answers0