Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crash when received notification for Android #2510

Closed
Niccolohui opened this issue May 7, 2020 · 6 comments
Closed

App crash when received notification for Android #2510

Niccolohui opened this issue May 7, 2020 · 6 comments
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. closed-by-bot Stale Issue with no recent activity

Comments

@Niccolohui
Copy link

Niccolohui commented May 7, 2020

Hi, the app crash in android when it got a notification from firebase. here is the log from Android studio. thank you!

I/flutter (12646): 360.0
I/dalvikvm(12646): Could not find method android.content.pm.PackageManager.isInstantApp, referenced from method com.google.android.gms.common.wrappers.PackageManagerWrapper.isCallerInstantApp
W/dalvikvm(12646): VFY: unable to resolve virtual method 702: Landroid/content/pm/PackageManager;.isInstantApp (Ljava/lang/String;)Z
D/dalvikvm(12646): VFY: replacing opcode 0x6e at 0x002e
D/AndroidRuntime(12646): Shutting down VM
W/dalvikvm(12646): threadid=1: thread exiting with uncaught exception (group=0x41756d58)
E/AndroidRuntime(12646): FATAL EXCEPTION: main
E/AndroidRuntime(12646): Process: com.sbchk.app, PID: 12646
E/AndroidRuntime(12646): java.lang.RuntimeException: Unable to create service io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService: java.lang.RuntimeException: PluginRegistrantCallback is not set.
E/AndroidRuntime(12646): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2585)
E/AndroidRuntime(12646): at android.app.ActivityThread.access$1900(ActivityThread.java:141)
E/AndroidRuntime(12646): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1295)
E/AndroidRuntime(12646): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(12646): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(12646): at android.app.ActivityThread.main(ActivityThread.java:5072)
E/AndroidRuntime(12646): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(12646): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(12646): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime(12646): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
E/AndroidRuntime(12646): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(12646): Caused by: java.lang.RuntimeException: PluginRegistrantCallback is not set.
E/AndroidRuntime(12646): at io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService.startBackgroundIsolate(FlutterFirebaseMessagingService.java:157)
E/AndroidRuntime(12646): at io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService.onCreate(FlutterFirebaseMessagingService.java:77)
E/AndroidRuntime(12646): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2575)
E/AndroidRuntime(12646): ... 10 more
I/Process (12646): Sending signal. PID: 12646 SIG: 9
Lost connection to device.
@TahaTesser
Copy link

Hi @Niccolohui
can you please provide your flutter doctor -v and flutter run --verbose?
Also, to better address the issue, would be helpful if you could post a minimal code sample to reproduce the problem
Thank you

@TahaTesser TahaTesser added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label May 8, 2020
@Niccolohui
Copy link
Author

Niccolohui commented May 8, 2020

Hi @TahaTesser

[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.4 19E287, locale en-HK)
• Flutter version 1.12.13+hotfix.9 at /Users/niccolo/Desktop/Programming/flutter
• Framework revision f139b11009 (6 weeks ago), 2020-03-30 13:57:30 -0700
• Engine revision af51afceb8
• Dart version 2.7.2

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/niccolo/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3.1, Build version 11C504
• CocoaPods version 1.9.1

[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 45.1.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[!] Connected device
! No devices available


[  +29 ms] executing: [/Users/niccolo/Desktop/Programming/flutter/] git -c log.showSignature=false log -n 1
--pretty=format:%H
[  +52 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] f139b11009aeb8ed2a3a3aa8b0066e482709dde3
[        ] executing: [/Users/niccolo/Desktop/Programming/flutter/] git describe --match v*.*.* --first-parent
--long --tags
[  +27 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] v1.12.13+hotfix.9-0-gf139b1100
[  +10 ms] executing: [/Users/niccolo/Desktop/Programming/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[  +14 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[        ] executing: [/Users/niccolo/Desktop/Programming/flutter/] git ls-remote --get-url origin
[  +11 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[  +63 ms] executing: [/Users/niccolo/Desktop/Programming/flutter/] git rev-parse --abbrev-ref HEAD
[  +12 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[   +6 ms] executing: sw_vers -productName
[  +14 ms] Exit code 0 from: sw_vers -productName
[        ] Mac OS X
[        ] executing: sw_vers -productVersion
[  +14 ms] Exit code 0 from: sw_vers -productVersion
[        ] 10.15.4
[        ] executing: sw_vers -buildVersion
[  +15 ms] Exit code 0 from: sw_vers -buildVersion
[        ] 19E287
[  +34 ms] executing: /usr/bin/xcode-select --print-path
[   +8 ms] Exit code 0 from: /usr/bin/xcode-select --print-path
[        ] /Applications/Xcode.app/Contents/Developer
[   +1 ms] executing: /usr/bin/xcodebuild -version
[  +99 ms] Exit code 0 from: /usr/bin/xcodebuild -version
[        ] Xcode 11.3.1
           Build version 11C504
[  +74 ms] executing: /Users/niccolo/Library/Android/sdk/platform-tools/adb devices -l
[   +6 ms] Exit code 0 from: /Users/niccolo/Library/Android/sdk/platform-tools/adb devices -l
[        ] List of devices attached
[  +15 ms] executing: /Users/niccolo/Desktop/Programming/flutter/bin/cache/artifacts/libimobiledevice/idevice_id
-h
[  +76 ms] /usr/bin/xcrun simctl list --json devices
[ +126 ms] No supported devices connected.
[  +14 ms] "flutter run" took 521ms.

#0      throwToolExit (package:flutter_tools/src/base/common.dart:28:3)
#1      RunCommand.validateCommand (package:flutter_tools/src/commands/run.dart:289:7)
<asynchronous suspension>
#2      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:590:11)
#3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:515:33)
<asynchronous suspension>
#4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:146:29)
#5      _rootRun (dart:async/zone.dart:1126:13)
#6      _CustomZone.run (dart:async/zone.dart:1023:19)
#7      _runZoned (dart:async/zone.dart:1518:10)
#8      runZoned (dart:async/zone.dart:1465:12)
#9      AppContext.run (package:flutter_tools/src/base/context.dart:145:18)
#10     FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:505:20)
#11     CommandRunner.runCommand (package:args/command_runner.dart:197:27)
#12     FlutterCommandRunner.runCommand.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command_runner.dart:413:21)
<asynchronous suspension>
#13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:146:29)
#14     _rootRun (dart:async/zone.dart:1126:13)
#15     _CustomZone.run (dart:async/zone.dart:1023:19)
#16     _runZoned (dart:async/zone.dart:1518:10)
#17     runZoned (dart:async/zone.dart:1465:12)
#18     AppContext.run (package:flutter_tools/src/base/context.dart:145:18)
#19     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:364:19)
#20     CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:112:25)
#21     new Future.sync (dart:async/future.dart:224:31)
#22     CommandRunner.run (package:args/command_runner.dart:112:14)
#23     FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:250:18)
#24     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:63:22)
#25     _rootRun (dart:async/zone.dart:1126:13)
#26     _CustomZone.run (dart:async/zone.dart:1023:19)
#27     _runZoned (dart:async/zone.dart:1518:10)
#28     runZoned (dart:async/zone.dart:1502:12)
#29     run.<anonymous closure> (package:flutter_tools/runner.dart:61:18)
<asynchronous suspension>
#30     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:146:29)
#31     _rootRun (dart:async/zone.dart:1126:13)
#32     _CustomZone.run (dart:async/zone.dart:1023:19)
#33     _runZoned (dart:async/zone.dart:1518:10)
#34     runZoned (dart:async/zone.dart:1465:12)
#35     AppContext.run (package:flutter_tools/src/base/context.dart:145:18)
#36     runInContext (package:flutter_tools/src/context_runner.dart:64:24)
#37     run (package:flutter_tools/runner.dart:50:10)
#38     main (package:flutter_tools/executable.dart:65:9)
#39     main
(file:///Users/niccolo/Desktop/Programming/flutter/packages/flutter_tools/bin/flutter_tools.dart:8:3)
#40     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:32)
#41     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)

@Niccolohui
Copy link
Author

Niccolohui commented May 8, 2020

`final Map<String, Item> _items = <String, Item>{};
Item _itemForMessage(Map<String, dynamic> message) {
  final String itemId = message['id'];
  final Item item = _items.putIfAbsent(itemId, () => new Item(itemId: itemId))
    ..status = message['status'];
  return item;
}

class Item {
  Item({this.itemId});
  final String itemId;

  StreamController<Item> _controller = new StreamController<Item>.broadcast();
  Stream<Item> get onChanged => _controller.stream;

  String _status;
  String get status => _status;
  set status(String value) {
    _status = value;
    _controller.add(this);
  }

  static final Map<String, Route<Null>> routes = <String, Route<Null>>{};
  Route<Null> get route {
    final String routeName = '/detail/$itemId';
    return routes.putIfAbsent(
      routeName,
      () => new MaterialPageRoute<Null>(
            settings: new RouteSettings(name: routeName),
            builder: (BuildContext context) => new DetailWidget(itemId),
          ),
    );
  }
}

 final FirebaseMessaging _firebaseMessaging = new FirebaseMessaging();
  //_firebaseMessaging.requestNotificationPermissions();

  //firebase!!!!!!!!!!!!!!!!
  final TextEditingController _topicController =
      new TextEditingController(text: 'topic');

  void _completeAlert(msg) {

   // var aps = jsonEncode(msg['aps']);

    var aps = msg['aps'];
    var alert = aps['alert'];

    print("ok");

    String body = alert['body'].toString();

    print(alert);

    // flutter defined function
    showDialog(
      context: context,
      builder: (BuildContext context) {
        // return object of type Dialog
        return new Container(
          decoration: new BoxDecoration(
            shape: BoxShape.rectangle,
            color: const Color(0xFFFFFF),
            borderRadius:
            new BorderRadius.all(new Radius.circular(20.0)),
          ),
          child: new AlertDialog(
            title: new Text("message"),
            content: new Text(body),
            actions: <Widget>[
              // usually buttons at the bottom of the dialog
              new FlatButton(
                child: new Text("CLOSE"),
                onPressed: () {
                  Navigator.of(context).pop();
                  //Navigator.of(context).pop();
                },
              ),
            ],
          ),
        );
      },
    );

  }

  void _showItemDialog(Map<String, dynamic> message) {
    showDialog<bool>(
      context: context,
      builder: (_) => _buildDialog(context, _itemForMessage(message)),
    ).then((bool shouldNavigate) {
      if (shouldNavigate == true) {
        _navigateToItemDetail(message);
      }
    });
  }




  void initState() {
    super.initState();
    tabController = new TabController(length: 3, vsync: this);
    _checkInCart();
    _checkLogin();
    //initDeviceId();

   // Vibrate.feedback(FeedbackType.selection);



    //================= fire base messaging start ====================


    _firebaseMessaging.configure(
      onMessage: (Map<String, dynamic> message) async {
        print("onMessage: $message");
        _completeAlert(message);
      },
      onBackgroundMessage: myBackgroundMessageHandler,
      onLaunch: (Map<String, dynamic> message) async {
        print("onLaunch: $message");
        _showItemDialog(message);
      },
      onResume: (Map<String, dynamic> message) async {
        print("onResume: $message");
        _showItemDialog(message);
      },
    );




    _firebaseMessaging.requestNotificationPermissions(
        const IosNotificationSettings(sound: true, badge: true, alert: true));
    _firebaseMessaging.onIosSettingsRegistered
        .listen((IosNotificationSettings settings) {
      print("Settings registered: $settings");
    });
    _firebaseMessaging.getToken().then((String token) {
      assert(token != null);
      setState(() {
        _homeScreenText = "Push Messaging token: $token";
        deviceToken = token;

        if(deviceToken!=global.userDeviceToken && global.userID!=""){


          _updateDeviceToken();

        }

      });
      print(_homeScreenText);
    });
    //================ end ==================
  }`


@TahaTesser TahaTesser removed the blocked: customer-response Waiting for customer response, e.g. more information was requested. label May 22, 2020
@TahaTesser
Copy link

TahaTesser commented May 22, 2020

Hi @Niccolohui
Trying official has no crash when receiving notification using `firebase_messaging: ^6.0.15
Your crash probably due to problem with your code and your code sample is not runnable
To better address the issue, would be helpful if you could post a runnable minimal code sample to reproduce the problem

flutter doctor -v
[✓] Flutter (Channel dev, 1.19.0-1.0.pre, on Mac OS X 10.15.4 19E287, locale
    en-GB)
    • Flutter version 1.19.0-1.0.pre at /Users/tahatesser/Code/flutter_dev
    • Framework revision 456d80b9dd (11 days ago), 2020-05-11 11:45:03 -0400
    • Engine revision d96f962ca2
    • Dart version 2.9.0 (build 2.9.0-7.0.dev 092ed38a87)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/tahatesser/Code/SDK
    • Platform android-29, build-tools 29.0.3
    • ANDROID_HOME = /Users/tahatesser/Code/SDK
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    • CocoaPods version 1.9.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.8052
    • Java version OpenJDK Runtime Environment (build
      1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.45.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.10.2

[✓] Connected device (5 available)
    • Android SDK built for x86 • emulator-5554             • android-x86    •
      Android 10 (API 29) (emulator)
    • Taha’s iPhone             • 00008020-001059882212002E • ios            •
      iOS 13.5
    • macOS                     • macOS                     • darwin-x64     •
      Mac OS X 10.15.4 19E287
    • Web Server                • web-server                • web-javascript •
      Flutter Tools
    • Chrome                    • chrome                    • web-javascript •
      Google Chrome 81.0.4044.138

• No issues found!

Thank you

@TahaTesser TahaTesser added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label May 22, 2020
@google-oss-bot google-oss-bot added the Stale Issue with no recent activity label Jul 30, 2020
@google-oss-bot
Copy link

Hey @Niccolohui. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@google-oss-bot
Copy link

Since there haven't been any recent updates here, I am going to close this issue.

@Niccolohui if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

@firebase firebase locked and limited conversation to collaborators Sep 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. closed-by-bot Stale Issue with no recent activity
Projects
None yet
Development

No branches or pull requests

3 participants