flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[firebase_messaging] Activity.getExternalFilesDir causes PlatformException

Open andreskiu opened this issue 6 years ago • 2 comments

Hello, I get this error when calling the configure method and i'm not sure why. I follow the instructions on the readme file. The only difference is i'm using gradle 3.3.0 intead of 3.5.3 because i cant upgrade it yet. Then, when a notifications message arrives to mi app, and the "onMessage" callback should run, the App closes without any warning or message. The same ocurrs if the app is on background.

However, before i have configured the callbacks (OnMessage, OnBackground...) the messages delivers fine to the notifications system's tray

Am i doing something wrong?

The error log after my call to "configure" method ( the relevant part)

E/flutter (22572): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'java.io.File android.app.Activity.getExternalFilesDir(java.lang.String)' on a null object reference, null)
E/flutter (22572): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter (22572): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
E/flutter (22572): <asynchronous suspension>
E/flutter (22572): #2      FirebaseMessaging.configure (package:firebase_messaging/firebase_messaging.dart:130:16)

I'm using firebase_messaging: 6.0.9

flutter doctor Doctor summary (to see all details, run flutter doctor -v):

[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Versión 10.0.18362.535], locale es-AR)

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[!] Android Studio (version 3.5)
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
[√] VS Code, 64-bit edition (version 1.41.1)
[√] Connected device (1 available)

! Doctor found issues in 1 category.
Build.gradle
dependencies {
 ...
    implementation 'com.google.firebase:firebase-messaging:20.1.0'
}

andreskiu avatar Jan 11 '20 19:01 andreskiu

Same issue here. I am currently using firebase_messaging 6.0.13 together with location 3.0.2. If I remove the location dependency from pubspec.yaml I have no error any more.

But I can't find out why. Has anyone else gained such knowledge?

fl-oe avatar Apr 15 '20 11:04 fl-oe

Closing in favour of trying the latest messaging version which has since this issue was created been heavily reworked to improve it along with detailed documentation: https://firebase.flutter.dev/docs/messaging/overview

If you still have a problem please raise a new GitHub issue with up to date information and code snippets if possible. Thanks.

Salakar avatar Apr 16 '21 09:04 Salakar