pusher / pusher-channels-flutter

Pusher Channels client library for Flutter targeting IOS, Android, and WEB
MIT License
72 stars 101 forks source link

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.pusher.client.channel.impl.message.AuthResponse.getChannelData()' on a null object reference #83

Closed gtu-myowin closed 1 year ago

gtu-myowin commented 1 year ago

I think the issue comes from pusher_beams_android package but I found similar issues in this repo. Therefore, I am posting my issue here.

The issues is when I debug my flutter app in Android emulator, it shows the splash screen and the app exited just after it. It only happening on Android and working fine on iOS simulator.

I have checked other issues and tried https://github.com/pusher/pusher-channels-flutter/issues/53#issuecomment-1237245577 and https://github.com/pusher/pusher-channels-flutter/issues/53#issuecomment-1237552296 but these answers didn't work for me. Thanks in advance for your kind help.

Here is the full stack

E/AndroidRuntime( 8901): FATAL EXCEPTION: pusher-java-client eventQueue
E/AndroidRuntime( 8901): Process: com.yuzanarland.app, PID: 8901
E/AndroidRuntime( 8901): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String
com.pusher.client.channel.impl.message.AuthResponse.getChannelData()' on a null object reference
E/AndroidRuntime( 8901): at com.pusher.client.channel.impl.PrivateChannelImpl.authorize(PrivateChannelImpl.java:84)
E/AndroidRuntime( 8901): at com.pusher.client.channel.impl.PrivateChannelImpl.toSubscribeMessage(PrivateChannelImpl.java:101)
E/AndroidRuntime( 8901): at com.pusher.client.channel.impl.ChannelManager.lambda$sendOrQueueSubscribeMessage$0$ChannelManager(ChannelManager.java:134)
E/AndroidRuntime( 8901): at com.pusher.client.channel.impl.-$$Lambda$ChannelManager$FgB2VuYy-N6QNBtpJxvJKKYHNmY.run(Unknown Source:4)
E/AndroidRuntime( 8901): at com.pusher.client.util.Factory.lambda$queueOnEventThread$0(Factory.java:140)
E/AndroidRuntime( 8901): at com.pusher.client.util.-$$Lambda$Factory$ipCpPRVuOGWb3qUOJ3_oRjSkk_Q.run(Unknown Source:2)
E/AndroidRuntime( 8901): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
E/AndroidRuntime( 8901): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
E/AndroidRuntime( 8901): at java.lang.Thread.run(Thread.java:1012)
I/Process ( 8901): Sending signal. PID: 8901 SIG: 9
Lost connection to device.
Exited

and here is my flutter doctor -v log

❯ flutter doctor -v
[✓] Flutter (Channel stable, 3.3.8, on macOS 13.0.1 22A400 darwin-x64, locale en-US)
    • Flutter version 3.3.8 on channel stable at /Users/myowin/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 52b3dc25f6 (2 days ago), 2022-11-09 12:09:26 +0800
    • Engine revision 857bd6b74c
    • Dart version 2.18.4
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/myowin/Library/Android/sdk
    • Platform android-33, build-tools 32.0.0
    • ANDROID_HOME = /Users/myowin/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/myowin/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.11.3

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

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

[✓] VS Code (version 1.74.0-insider)
    • VS Code at /Applications/Visual Studio Code - Insiders.app/Contents
    • Flutter extension version 3.52.0

[✓] Connected device (2 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 13 (API 33) (emulator)
    • macOS (desktop)              • macos         • darwin-x64  • macOS 13.0.1 22A400 darwin-x64

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Please let me know if you need further information.

gtu-myowin commented 1 year ago

I am sorry this doesn't related to pusher at all. There was something wrong with onAuthorizer and turns out it was it backend which is returning a HTML document when authorizing fail. Closing the issue now.