The parameter json is filled with keys:'a', 'b', 'c' and 'd' when in release mode, instead of 'connected', 'message', 'errorCode' and 'errorDetails'. The values are ok but the json keys are wrong.
As a temporary workaround I modified two files:
First, I added this import at the very top of the file: C:\Users\{USERNAME}\AppData\Local\Pub\Cache\hosted\pub.dev\spotify_sdk-3.0.2\lib\models\connection_status.dart
import 'package:flutter/foundation.dart';
Second, I modified this function on the file: C:\Users\{USERNAME}\AppData\Local\Pub\Cache\hosted\pub.dev\spotify_sdk-3.0.2\lib\models\connection_status.g.dart
ConnectionStatus _$ConnectionStatusFromJson(Map<String, dynamic> json) {
if (kReleaseMode) {
return ConnectionStatus(
json['b'] as String?,
json['c'] as String?,
json['d'] as String?,
connected: json['a'] as bool,
);
} else {
return ConnectionStatus(
json['message'] as String?,
json['errorCode'] as String?,
json['errorDetails'] as String?,
connected: json['connected'] as bool,
);
}
}
After the changes ConnectionStatus seems to work properly.
Is this a how to question? No
Is this a native Spotify SDK issue? No
Have you searched for existing issues? Yes
Are you using a Free or Premium Spotify account? Premium
Are you aware of the limitations of Free Spotify accounts? Yes
Expected behavior Connection Status subscription works in android release mode
Describe the bug SpotifySdk.subscribeConnectionStatus() doesn't work when compiled in release mode on android.
Steps to Reproduce Steps to reproduce the behavior:
Spotify_sdk Flutter package version 3.0.2
Flutter version 3.24.3
Target Platform, Version & Device
Development OS
That bug only happens in release mode (on Android), where the Connection Status does not work correctly due to probably a parsing problem.
Found out that:
In the function ConnectionStatus _$ConnectionStatusFromJson(Map<String, dynamic> json) in the file:
"C:\Users{USERNAME}\AppData\Local\Pub\Cache\hosted\pub.dev\spotify_sdk-3.0.2\lib\models\connection_status.g.dart"
The parameter json is filled with keys:'a', 'b', 'c' and 'd' when in release mode, instead of 'connected', 'message', 'errorCode' and 'errorDetails'. The values are ok but the json keys are wrong.
As a temporary workaround I modified two files:
First, I added this import at the very top of the file:
C:\Users\{USERNAME}\AppData\Local\Pub\Cache\hosted\pub.dev\spotify_sdk-3.0.2\lib\models\connection_status.dart
import 'package:flutter/foundation.dart';
Second, I modified this function on the file:
C:\Users\{USERNAME}\AppData\Local\Pub\Cache\hosted\pub.dev\spotify_sdk-3.0.2\lib\models\connection_status.g.dart
After the changes ConnectionStatus seems to work properly.