首页 > 解决方案 > Problem with spotify_sdk connection in flutter

问题描述

I am newbie in Flutter and with the Spotify SDK. I am using spotify_sdk 2.1.0 Here is my code :

 Future<void> connect() async {
    print("BEGIN");
    try {
      await SpotifySdk.connectToSpotifyRemote(
          clientId: "<ID>", redirectUrl: "copilot://callback");

      var isActive = await SpotifySdk.isSpotifyAppActive;
      String snackBar = isActive
              ? 'Spotify app connection is active (currently playing)'
              : 'Spotify app connection is not active (currently not playing)';

      print(snackBar);

    } on PlatformException catch (e) {
      print("PE");
    } on MissingPluginException {
      print("MPE");
    } on Exception {
      print('what');
    }
  }

  Future<void> disconnect() async {
    try {
      var result = await SpotifySdk.disconnect();
    } on PlatformException catch (e) {
      print("PlatExcep");
    } on MissingPluginException {
      print("sd");
    }
  }

I want to connect to Spotify App in Flutter and skip song with my app but when i try to connect I have this :

W/zingkas.copilo(30050): Unable to resolve Lcom/spotify/protocol/types/HelloDetails; annotation class 2032
W/zingkas.copilo(30050): Unable to resolve Lcom/spotify/protocol/types/HelloDetails; annotation class 2035
I/chatty  (30050): uid=10222(com.freezingkas.copilot) AsyncTask #2 identical 6 lines
W/zingkas.copilo(30050): Unable to resolve Lcom/spotify/protocol/types/HelloDetails; annotation class 2035
W/zingkas.copilo(30050): Unable to resolve Lcom/spotify/protocol/types/Info; annotation class 2032
W/zingkas.copilo(30050): Unable to resolve Lcom/spotify/protocol/types/Info; annotation class 2035
I/chatty  (30050): uid=10222(com.freezingkas.copilot) AsyncTask #2 identical 1 line
W/zingkas.copilo(30050): Unable to resolve Lcom/spotify/protocol/types/Info; annotation class 2035
W/zingkas.copilo(30050): Unable to resolve Lcom/spotify/protocol/types/Info; annotation class 2035
I/chatty  (30050): uid=10222(com.freezingkas.copilot) AsyncTask #2 identical 19 lines
W/zingkas.copilo(30050): Unable to resolve Lcom/spotify/protocol/types/Info; annotation class 2035
W/zingkas.copilo(30050): Unable to resolve Lcom/spotify/protocol/types/HelloDetails; annotation class 2035
W/zingkas.copilo(30050): Unable to resolve Lcom/spotify/protocol/types/HelloDetails; annotation class 2035
W/zingkas.copilo(30050): Unable to resolve Lcom/spotify/protocol/types/Roles; annotation class 2032
W/zingkas.copilo(30050): Unable to resolve Lcom/spotify/protocol/types/Roles; annotation class 2035
I/chatty  (30050): uid=10222(com.freezingkas.copilot) AsyncTask #2 identical 3 lines
W/zingkas.copilo(30050): Unable to resolve Lcom/spotify/protocol/types/Roles; annotation class 2035
W/zingkas.copilo(30050): Unable to resolve Lcom/spotify/protocol/types/Roles; annotation class 2035
I/chatty  (30050): uid=10222(com.freezingkas.copilot) AsyncTask #2 identical 1 line
W/zingkas.copilo(30050): Unable to resolve Lcom/spotify/protocol/types/Roles; annotation class 2035

After this I tried to skip the song but it did not works.

And when I try to disconnect, I have this :

E/MethodChannel#spotify_sdk(30050): Failed to handle method call
E/MethodChannel#spotify_sdk(30050): java.lang.NullPointerException
E/MethodChannel#spotify_sdk(30050):     at de.minimalme.spotify_sdk.SpotifySdkPlugin.disconnectFromSpotify(SpotifySdkPlugin.kt:280)
E/MethodChannel#spotify_sdk(30050):     at de.minimalme.spotify_sdk.SpotifySdkPlugin.onMethodCall(SpotifySdkPlugin.kt:130)
E/MethodChannel#spotify_sdk(30050):     at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#spotify_sdk(30050):     at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#spotify_sdk(30050):     at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/MethodChannel#spotify_sdk(30050):     at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#spotify_sdk(30050):     at android.os.MessageQueue.next(MessageQueue.java:335)
E/MethodChannel#spotify_sdk(30050):     at android.os.Looper.loop(Looper.java:193)
E/MethodChannel#spotify_sdk(30050):     at android.app.ActivityThread.main(ActivityThread.java:7876)
E/MethodChannel#spotify_sdk(30050):     at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#spotify_sdk(30050):     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
E/MethodChannel#spotify_sdk(30050):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
I/flutter (30050): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (30050): │ #0   SpotifySdk._logException (package:spotify_sdk/spotify_sdk.dart:609:15)
I/flutter (30050): │ #1   SpotifySdk.disconnect (package:spotify_sdk/spotify_sdk.dart:133:7)
I/flutter (30050): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (30050): │  disconnectFromSpotify failed with: 
I/flutter (30050): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (30050): PlatExcep

I don't know if my question is stupid but didn't find any solutions on Internet.

标签: androidflutterspotify

解决方案


推荐阅读