Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UAMP for automotive OS throws exception when running debug #412

Closed
scritz opened this issue Oct 14, 2020 · 2 comments · Fixed by #426
Closed

UAMP for automotive OS throws exception when running debug #412

scritz opened this issue Oct 14, 2020 · 2 comments · Fixed by #426
Assignees
Labels
auto-os Android Automotive OS bug
Milestone

Comments

@scritz
Copy link

scritz commented Oct 14, 2020

(Likely same issue as #409)
When trying to debug the Automotive version of UAMP you get exception (see EXCEPTION1 below) straight away when trying to debug. The reasons seems to be related to gms.cast.framework and no included optionsprovider.

If I include the missing section in automotive manifest from the phone app manifest:

<meta-data android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
            android:value="com.example.android.uamp.cast.UampCastOptionsProvider"/>

I get a new exception: See EXCEPTION2 below. Perhaps not so strange, since it seems as the optionsprovider is not included in the automotive build.

EXCEPTION1:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.uamp.next, PID: 7512
java.lang.RuntimeException: Unable to create service com.example.android.uamp.automotive.AutomotiveMusicService: java.lang.IllegalStateException: The fully qualified name of the implementation of OptionsProvider must be provided as a metadata in the AndroidManifest.xml with key com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME.
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3585)
at android.app.ActivityThread.access$1300(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1675)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6728)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.IllegalStateException: The fully qualified name of the implementation of OptionsProvider must be provided as a metadata in the AndroidManifest.xml with key com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME.
at com.google.android.gms.cast.framework.CastContext.zzb(com.google.android.gms:play-services-cast-framework@@18.1.0:23)
at com.google.android.gms.cast.framework.CastContext.getSharedInstance(com.google.android.gms:play-services-cast-framework@@18.1.0:3)
at com.example.android.uamp.media.MusicService$castPlayer$2.invoke(MusicService.kt:152)
at com.example.android.uamp.media.MusicService$castPlayer$2.invoke(MusicService.kt:88)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.example.android.uamp.media.MusicService.getCastPlayer(Unknown Source:2)
at com.example.android.uamp.media.MusicService.onCreate(MusicService.kt:212)
at com.example.android.uamp.automotive.AutomotiveMusicService.onCreate(AutomotiveMusicService.kt:61)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3573)
at android.app.ActivityThread.access$1300(ActivityThread.java:200) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1675) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:193) 
at android.app.ActivityThread.main(ActivityThread.java:6728) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
I/Process: Sending signal. PID: 7512 SIG: 9

EXCEPTION2:
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.uamp.automotive, PID: 7229
java.lang.RuntimeException: Unable to create service com.example.android.uamp.automotive.AutomotiveMusicService: java.lang.IllegalStateException: Failed to initialize CastContext.
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3585)
at android.app.ActivityThread.access$1300(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1675)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6728)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.IllegalStateException: Failed to initialize CastContext.
at com.google.android.gms.cast.framework.CastContext.zzb(com.google.android.gms:play-services-cast-framework@@18.1.0:30)
at com.google.android.gms.cast.framework.CastContext.getSharedInstance(com.google.android.gms:play-services-cast-framework@@18.1.0:3)
at com.example.android.uamp.media.MusicService$castPlayer$2.invoke(MusicService.kt:152)
at com.example.android.uamp.media.MusicService$castPlayer$2.invoke(MusicService.kt:88)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.example.android.uamp.media.MusicService.getCastPlayer(Unknown Source:2)
at com.example.android.uamp.media.MusicService.onCreate(MusicService.kt:212)
at com.example.android.uamp.automotive.AutomotiveMusicService.onCreate(AutomotiveMusicService.kt:61)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3573)
at android.app.ActivityThread.access$1300(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1675)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6728)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: com.example.android.uamp.cast.UampCastOptionsProvider
at java.lang.Class.classForName(Native Method)

@scritz
Copy link
Author

scritz commented Oct 14, 2020

After some more investigation I have found that the issue is related to musicservice.kt. Since this class is in the "common" part of the phone and automotive app the usage of the CastPlayer causes the automotive app to crash (automotive perhaps does not support cast?). I have not yet solved the issue, just verified that if I remove the castplayer from MusicService.kt I can get the app running on automotive version.

@dturner dturner added auto-os Android Automotive OS bug quick-fix Stuff which can be fixed in less than 10 mins labels Dec 4, 2020
@dturner dturner self-assigned this Dec 4, 2020
@dturner dturner added this to the Next milestone Dec 4, 2020
@dturner
Copy link
Contributor

dturner commented Dec 8, 2020

Thanks for raising this. You're right, automotive OS doesn't support Cast. We need to make some significant architectural changes to MusicService to make this work correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-os Android Automotive OS bug
2 participants