Music Kit Integration Issue: Requesting Developer Token on Android

46 Views Asked by At

I have integrated music_kit version 1.1.0 into my Flutter app, and I was able to successfully obtain the developer token and user token on iOS. However, I am encountering issues with the same flow on Android.

From what I understand, the plugin on iOS directly extracts information from the device, but on Android, it seems to require an authentication/login flow since it's more of an app integration where we initiate the login process manually. However, this automatic flow is not happening as expected on Android.

By default, I am receiving the following error:

PlatformException(requestDeveloperToken, null, java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at app.misi.music_kit.ChannelHandler.onMethodCall(ChannelHandler.kt:123)
    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)
    at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
    at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
    at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:250)
    at android.app.ActivityThread.main(ActivityThread.java:7886)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at co

I've attempted to add the following activity to the AndroidManifest.xml file:

<activity
    android:name="com.apple.android.sdk.authentication.SDKUriHandlerActivity"
    android:launchMode="singleTask"
    android:screenOrientation="portrait"
    android:exported="true"
    android:theme="@style/MusicKitAuthTheme" >
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:host="${applicationId}"
            android:pathPattern="/spotify.*"
            android:scheme="musicsdk" />
    </intent-filter>
</activity>

However, I'm still encountering the same error. Any guidance on how to resolve this issue and enable the correct authentication flow on Android would be greatly appreciated. Thank you!

0

There are 0 best solutions below