Skip to content

PushNotificationException "Error occurred awaiting for device token." #5119

@ClemPalf

Description

@ClemPalf

Description

Hi,

I am having trouble setting up push-notifications for android.
I would suspect that the extra step I add to take (in addition to your documentation) to add the com.google.gms.google-services plugin is what is causing the error.

Regards,

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

I first encountered an issue at this stage :
image
Simply adding the line apply plugin: 'com.google.gms.google-services' to my app/build.gradle created the following error :

  • Where:
    Build file '/Users/clem/Documents/Morp/morp_alpha/android/app/build.gradle' line: 101

  • What went wrong:
    A problem occurred evaluating project ':app'.

Plugin with id 'com.google.gms.google-services' not found.

I finally managed to compile the app by :

  1. Adding this code snippet to my android/build.gradle file :
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.4.2'
    }
}
  1. Adding the google-services.json file provided by firebase in my android/app folder.

However, I now get the following runtime error when running Amplify.configure(amplifyconfig):

E/flutter ( 5262): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PushNotificationException { E/flutter ( 5262): "message": "Error occurred awaiting for device token.", E/flutter ( 5262): "recoverySuggestion": "Review the underlying exception.", E/flutter ( 5262): "underlyingException": "PlatformException(java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.morp.morp_alpha. Make sure to call FirebaseApp.initializeApp(Context) first., IllegalStateException, Cause: null, Stacktrace: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.morphit.morphit_alpha. Make sure to call FirebaseApp.initializeApp(Context) first.\n\tat com.google.firebase.FirebaseApp.getInstance(FirebaseApp.java:179)\n\tat com.google.firebase.messaging.FirebaseMessaging.getInstance(FirebaseMessaging.java:137)

Screenshots

No response

Platforms

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

3.22.2

Amplify Flutter Version

2.2.0

Deployment Method

AWS CDK

Schema

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions