advplyr / audiobookshelf-app

Mobile application for Audiobookshelf
https://audiobookshelf.org
GNU General Public License v3.0
1.22k stars 166 forks source link

[Enhancement] Android TV Support #606

Open moozhub opened 1 year ago

moozhub commented 1 year ago

Love your app, but it crashes immediately on ATV. Any plans for support on ATV?

Steps to reproduce

  1. Install
  2. Open
  3. Observe crash

Expected behaviour

At least open

Actual behaviour

Crashes immediately

Environment data

Rooted Lineageos 19 kernel version 4.9.113

Audiobookshelf Version: 0.9.62-beta

Android Issue

Android version: ATV 12

Device model: ODroid-n2+

Stock or customized system: Custom rooted Lineageos 19 ATV 12 on ODroid-n2+

advplyr commented 1 year ago

I don't have an Android TV so not something I would develop at the moment. Someone else may help though.

Are you able to install the app through the play store on your Android TV?

moozhub commented 1 year ago

I don't have an Android TV so not something I would develop at the moment. Someone else may help though.

Are you able to install the app through the play store on your Android TV?

No, the playstore is pretty limited on ATV, but manually downloading the APK and installing it works fine, as far as I know the repositories for a regular Android device and ATV are separate but as far as that I don't know the details around what makes it into the ATV repo.. I can provide the ROM if you're interested in installing it in a virtual environment, or I can try to provide any details you might want.

Thanks for the quick reply

advplyr commented 1 year ago

Got it. If the app was being listed on the Android TV play store then this would be a bug, but since it is not supported at the moment this is a feature request.

Similar to Android Auto we have to declare that this is Android TV compatible then the Google team reviews it.

A developer with an Android TV might come along and help with this.

moozhub commented 1 year ago

Got it. If the app was being listed on the Android TV play store then this would be a bug, but since it is not supported at the moment this is a feature request.

Similar to Android Auto we have to declare that this is Android TV compatible then the Google team reviews it.

A developer with an Android TV might come along and help with this.

Here's some info that I gathered that might be of assistance some time in the future..

02-25 15:41:17.419  8711  8711 D AndroidRuntime: Shutting down VM                                                           
02-25 15:41:17.419  8711  8711 E AndroidRuntime: FATAL EXCEPTION: main                                                      
02-25 15:41:17.419  8711  8711 E AndroidRuntime: Process: com.audiobookshelf.app, PID: 8711                                 
02-25 15:41:17.419  8711  8711 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.audiobookshelf.app/com.audiobookshelf.app.MainActivity}: java.lang.RuntimeException: com.google.android.gms.cast.framework.zzat: com.google.android.gms.dynamite.DynamiteModule$LoadingException: No acceptable module com.google.android.gms.cast.framework.dynamite found. Local version is 0 and remote version is 0.  
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3707)                                                     
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3864)                                                      
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)                                          
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)                               
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)                                         
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2253)                                                           
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:106)             
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at android.os.Looper.loopOnce(Looper.java:201)                      
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:288)                          
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:7870)        
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)                   
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)                                              
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)    
02-25 15:41:17.419  8711  8711 E AndroidRuntime: Caused by: java.lang.RuntimeException: com.google.android.gms.cast.framework.zzat: com.google.android.gms.dynamite.DynamiteModule$LoadingException: No acceptable module com.google.android.gms.cast.framework.dynamite found. Local version is 0 and remote version is 0.                                                         
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.google.android.gms.cast.framework.CastContext.getSharedInstance(com.google.android.gms:play-services-cast-framework@@20.1.0:8)                                                           
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.audiobookshelf.app.player.CastManager.getContext(CastManager.kt:309)                                                       
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.audiobookshelf.app.player.CastManager.access$getContext(CastManager.kt:19)                                                 
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.audiobookshelf.app.player.CastManager$startRouteScan$callback$1.onRouteUpdate(CastManager.kt:128)                          
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.audiobookshelf.app.player.CastManager$ScanCallback.onFilteredRouteUpdate(CastManager.kt:246)                               
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.audiobookshelf.app.player.CastManager.startRouteScan(CastManager.kt:152)                                                   
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.audiobookshelf.app.plugins.AbsAudioPlayer.initCastManager(AbsAudioPlayer.kt:169)                                           
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.audiobookshelf.app.plugins.AbsAudioPlayer.load(AbsAudioPlayer.kt:40)                                                       
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.getcapacitor.PluginHandle.loadInstance(PluginHandle.java:115)
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.getcapacitor.PluginHandle.load(PluginHandle.java:105)        
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.getcapacitor.PluginHandle.<init>(PluginHandle.java:65)       
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.getcapacitor.Bridge.registerPlugin(Bridge.java:627)          
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.getcapacitor.Bridge.registerAllPlugins(Bridge.java:583)      
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.getcapacitor.Bridge.<init>(Bridge.java:210)                  
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.getcapacitor.Bridge.<init>(Unknown Source:0)                 
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.getcapacitor.Bridge$Builder.create(Bridge.java:1502)         
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.getcapacitor.BridgeActivity.load(BridgeActivity.java:43)     
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.getcapacitor.BridgeActivity.onCreate(BridgeActivity.java:37) 
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.audiobookshelf.app.MainActivity.onCreate(MainActivity.kt:61) 
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at android.app.Activity.performCreate(Activity.java:8057)           
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at android.app.Activity.performCreate(Activity.java:8037)           
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1341)                                                    
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3688)                                                     
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        ... 12 more                                                         
02-25 15:41:17.419  8711  8711 E AndroidRuntime: Caused by: com.google.android.gms.cast.framework.zzat: com.google.android.gms.dynamite.DynamiteModule$LoadingException: No acceptable module com.google.android.gms.cast.framework.dynamite found. Local version is 0 and remote version is 0.                       
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.google.android.gms.internal.cast.zzm.zzf(com.google.android.gms:play-services-cast-framework@@20.1.0:7)                    
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.google.android.gms.internal.cast.zzm.zza(com.google.android.gms:play-services-cast-framework@@20.1.0:1)                    
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.google.android.gms.cast.framework.CastContext.<init>(com.google.android.gms:play-services-cast-framework@@20.1.0:4)        
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at 
com.google.android.gms.cast.framework.CastContext.getSharedInstance(com.google.android.gms:play-services-cast-framework@@20.1.0:7)                                                           
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        ... 34 more                                                         
02-25 15:41:17.419  8711  8711 E AndroidRuntime: Caused by: com.google.android.gms.dynamite.DynamiteModule$LoadingException: No acceptable module com.google.android.gms.cast.framework.dynamite found. Local version is 0 and remote version is 0.     
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.google.android.gms.dynamite.DynamiteModule.load(com.google.android.gms:play-services-basement@@18.0.0:65)                  
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        at com.google.android.gms.internal.cast.zzm.zzf(com.google.android.gms:play-services-cast-framework@@20.1.0:2)                    
02-25 15:41:17.419  8711  8711 E AndroidRuntime:        ... 37 more                                                         
02-25 15:41:17.425  3639  3665 W ActivityTaskManager:   Force finishing activity com.audiobookshelf.app/.MainActivity

Some of that might not be relevant, there's a lot of stuff in my log so apologies.

moozhub commented 1 year ago

Updated to look prettier

advplyr commented 1 year ago

Thanks, the error makes sense since we have not declared a TV activity. https://developer.android.com/training/tv/start/start#tv-activity

moozhub commented 1 year ago

Thanks, the error makes sense since we have not declared a TV activity. https://developer.android.com/training/tv/start/start#tv-activity

Cool, looks like that is a start. I can test any updates you might want to throw at me. Thanks for the efforts.

galaxyfar commented 1 year ago

FYI, ran into the exact same issue on one of my Android TV last week.

After dumping the log and looking around of answers, I figured instant crash was happening due to outdate Google play services. Sideloaded latest play services apk and everything works like a charm, no more crash.

This issue is not ATV per se but specific to certain ATV devices because same app works right out of the box on Nvidia shield TV.

moozhub commented 1 year ago

FYI, ran into the exact same issue on one of my Android TV last week.

After dumping the log and looking around of answers, I figured instant crash was happening due to outdate Google play services. Sideloaded latest play services apk and everything works like a charm, no more crash.

This issue is not ATV per se but specific to certain ATV devices because same app works right out of the box on Nvidia shield TV.

Are you using the Google play services for ATV? What version of ATV are you using (what Android version) and what play services version did you sideload? I'll give it a shot.

Thanks

galaxyfar commented 1 year ago

Android TV in question was running Android 11. It's el cheapo Google certified TV box from Mecool, came preinstalled with Google play services/store but for some reason was not getting any apps updates from Play store and ABS app was not even showing up.

So I just sideloaded google-play-services-23-06-16-040400-510240997.apk from apkmirror and voila, it all started working.

moozhub commented 1 year ago

Android TV in question was running Android 11. It's el cheapo Google certified TV box from Mecool, came preinstalled with Google play services/store but for some reason was not getting any apps updates from Play store and ABS app was not even showing up.

So I just sideloaded google-play-services-23-06-16-040400-510240997.apk from apkmirror and voila, it all started working.

I see.

I think what you did was sideloaded the regular Google play services (the one for mobile devices, and not the one for ATV). If that's what you did that would make sense that it shows up in the playstore after you installed it, since the device you installed it on is no longer being registered with the play store as an ATV device, but as a mobile device.

While I'm not sure of all the repercussions of that I do know that the device you installed it on is technically no longer an ATV device (at least from the perspective of the apps you install, and some features potentially may not function the way you would expect).

I still may try it just to play around with it but having the software installed on ATV using ATV play services and ATV playstore would be most ideal.

nathanmilot commented 1 year ago

I was able to sideload it and open the app, but navigation doesn't work properly. It only selects the main section headings but is missing the ability to actually select audiobooks or navigate to the player. Might try to take a stab at it at some point if I get any time.

https://developer.android.com/training/tv/start/navigation

advplyr commented 1 year ago

@nathanmilot I haven't looked into this yet but peeking at those docs I don't see anything about controlling navigation using WebView. The UI of the app is WebView so it can be shared between android and ios. It may be as easy as implementing tabindexes

nathanmilot commented 1 year ago

Oh nice. Yeah hadn't looked at the codebase too in depth.

clockwinder commented 10 months ago

I would love to see support for this as well, unofficial is fine by me as well since it's easy to sideload.

After sideloading the ABS android app (V0.9.68) onto my Chromecast with TV, I had the same navigation issues. The setup is easy to replicate on an android device by just connecting a keyboard and navigating using the arrow keys/enter. It's already seems close to working!

I'm not sure if anyone's made a note of this, but adding this functionality does have some accessibility potential as well by giving an alternative method of navigation.

steve1123456 commented 7 months ago

I was able to sideload it and open the app, but navigation doesn't work properly. It only selects the main section headings but is missing the ability to actually select audiobooks or navigate to the player. Might try to take a stab at it at some point if I get any time.

https://developer.android.com/training/tv/start/navigation

This! I'm in the same boat. Can login but can't scroll to books.

A workaround I've found is to install a Mouse app, which actually works and does the job, but it's a bit clunky. Would be ideal to simply click down on the firestick and navigate around the books.

Fantastic app by the way!

colvdv commented 7 months ago

A workaround I've found is to install a Mouse app, which actually works and does the job, but it's a bit clunky.

I too found a workaround: Accessing through Silk Browser.

I then installed Bookmarker to bookmark the page for quick access. Navigation isnt the most convenient, scrolling for example must be done by clicking on the scroll bar, but it works.

This isn't too much hassle for me, but I have grandparents that I'm looking out for and easier navigation makes a world of difference for them. Doing my best to give them alternatives for entertainment to the BS on TV.