android - 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.
解决方案
推荐阅读
- ruby - Ruby 中的 Coinbase API 请求总是返回 Invalid API Key
- vue.js - 使用 vue-fontawesome 导入常规和实心图标
- javascript - Bootstrap 5 ScrollSpy 偏移,用于固定底部菜单并响应屏幕大小
- node.js - 遍历数组并改变对象值
- android - 如何使用 Unity IAP 在 Android 应用程序中升级/降级订阅
- javascript - 在 Hello World 简单项目中未加载 Bootstrap Javascript
- spring-boot - 在 oauth2 之前保留表单数据(spring security + spring boot)
- rust - 如何在没有任何 crate 的情况下进行 DNS 查找?
- spring - 即使仅使用父类,也会在继承的类上触发 Hibernate 自定义验证
- visual-studio-code - 如何更改问题选项卡的字体大小?