brim-borium/spotify_sdk

subscribeConnectionStatus on Android release build crashes due to null safety

sidak003 opened this issue ยท 11 comments

Describe the bug
subscribeConnectionStatus does not work or crashes due to null safety on Android Release Build but in debug mode works properly. I am currently on version 2.1.0 ~latest and here is the log when it crashes due to null safety:

E/flutter ( 8658): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: type 'Null' is not a subtype of type 'bool' in type cast
E/flutter ( 8658): #0      _$ConnectionStatusFromJson (package:spotify_sdk/models/connection_status.g.dart:16)
E/flutter ( 8658): #1      new ConnectionStatus.fromJson (package:spotify_sdk/models/connection_status.dart:29)
E/flutter ( 8658): #2      SpotifySdk.subscribeConnectionStatus.<anonymous closure> (package:spotify_sdk/spotify_sdk.dart:324)
E/flutter ( 8658): #3      Stream.asyncMap.<anonymous closure>.<anonymous closure> (dart:async/stream.dart:554)
E/flutter ( 8658): #4      _rootRunUnary (dart:async/zone.dart:1362)
E/flutter ( 8658): #5      _CustomZone.runUnary (dart:async/zone.dart:1265)
E/flutter ( 8658): #6      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170)
E/flutter ( 8658): #7      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341)
E/flutter ( 8658): #8      _DelayedData.perform (dart:async/stream_impl.dart:591)
E/flutter ( 8658): #9      _StreamImplEvents.handleNext (dart:async/stream_impl.dart:706)
E/flutter ( 8658): #10     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:663)
E/flutter ( 8658): #11     _rootRun (dart:async/zone.dart:1346)
E/flutter ( 8658): #12     _CustomZone.run (dart:async/zone.dart:1258)
E/flutter ( 8658): #13     _CustomZone.runGuarded (dart:async/zone.dart:1162)
E/flutter ( 8658): #14     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202)
E/flutter ( 8658): #15     _rootRun (dart:async/zone.dart:1354)
E/flutter ( 8658): #16     _CustomZone.run (dart:async/zone.dart:1258)
E/flutter ( 8658): #17     _CustomZone.runGuarded (dart:async/zone.dart:1162)
E/flutter ( 8658): #18     _CustomZone.bindCallbackGuarded.<anonymous closure> `(dart:async/zone.dart:1202

NOTE: I have already checked #91 but couldn't found a fix

To Reproduce
Steps to reproduce the behavior:

  1. Just call SpotifySdk.subscribeConnectionStatus()
  2. Run the build in release mode

Expected behavior
Error due to Null Safety or nothing happens

Desktop (please complete the following information):

  • OS: [Windows 10]
  • Version [20H2]

Smartphone (please complete the following information):

  • Device: [Redmi 5 Plus]
  • OS: [Android]
  • Version [10]

Hey @brim-borium sorry to disturb, may you have a view at this issue

@Sidak100 can you reproduce the same issue with the example app and the latest version from the main branch? Are you sure that you configured your project correctly? I was not able to reproduce it.

@Sidak100 can you reproduce the same issue with the example app and the latest version from the main branch? Are you sure that you configured your project correctly? I was not able to reproduce it.

Yes I tried the same with example app, still same issue. Regarding configuring I tried method provided in #99

@Sidak100 how are you building the app? In release mode no logs are printed. Can you please describe in detail the steps you do?

@Sidak100 how are you building the app? In release mode no logs are printed. Can you please describe in detail the steps you do?

The app working is simple, it subscribes to connection status and when connection is sucess or gets true it does certain things like bring the user data ~same as example app.
Actually in release mode when I connect to spotify using remote, it gets the connection object as null which is supposed to be a boolean, this gives the log error as in 1st comment. Although it is connected to spotify I can play pause tracks but can't get status.
In debug mode works fine no error no log.

The same thing happens to me. Managed to solve?

The same thing happens to me. Managed to solve?

Try these commands for release build

flutter build apk --no-shrink

or

flutter build apk --split-per-abi --no-shrink

Although I didn't tried since I am out of home but let me know immediately if it works ๐Ÿ‘Š๐Ÿป

it didn't work

Sorry for the delay, but I'm in a different time zone, I'm in Brazil.

@alanhmartins found the issue:

Because of obfuscating on the android side on release branches, some model keys had been renamed during the release build and that lead to a problem during decoding of the returning jsons

Should be fixed with #146

@alanhmartins found the issue:

Because of obfuscating on the android side on release branches, some model keys had been renamed during the release build and that lead to a problem during decoding of the returning jsons

Should be fixed with #146

Thanks a lot buddy ๐Ÿ‘Š๐Ÿป

@Sidak100 @alanhmartins
Just released v2.2.0 of the package, feel free to test if everything still works for you :)