Hacking your Android TV

I have a love/hate relationship with Youtube. I love the content, I hate the algorithm. I hate shorts. I hate the ads, and also the sponsors. That’s a lot of annoying crap to deal with. Never have I paid for a subscription and still had to route around so much damage.

Additionally on Android TV, there is the ‘launcher’ which is an app that runs at startup that is slow, mainly because its a vehicle to show me even more ads, and doesn’t really provide much utility.

But hey, this is Android, meaning that you can actually do something about this, which is great. I have a Sony Bravia Android TV. You can connect to it via adb and install things.

Install Smarttube

I use SmartTube which also uses SponsorBlock and Dearrow to improve the Youtube experience dramatically. So first step here is to install Smarttube via sideloading. This isn’t an in-depth ‘how to install android apps’ tutorial but basically:

Install Flauncher

Flauncher is basically a very minimal launcher app(aka a home screen) to replace the gold-plated ad machine Google now loads on your machine. Google’s launcher is a package called launcherx that you’ll need to disable in order to enable Flauncher.

Simple instructions are available here on their git page to disable Google junk and enable Flauncher. I’ll copy them here for completeness:

# Disable com.google.android.apps.tv.launcherx which is the default launcher on CCwGTV
$ adb shell pm disable-user --user 0 com.google.android.apps.tv.launcherx
# com.google.android.tungsten.setupwraith will then be used as a 'fallback' and will automatically
# re-enable the default launcher, so disable it as well
$ adb shell pm disable-user --user 0 com.google.android.tungsten.setupwraith

Caveat!

When you disable the built-in launcher and enable Flauncher, you’re actually disabling a dependency that the youtube app, and possibly other google apps, rely on. This is where google’s account system lies. So if you ever need to sign in, or re-login, to Youtube then this will essentially completely break the Youtube app and it will hang with an ActivityNotFoundException.

In order to fix this you’ll need to re-enable launcherx to log in, then disable again to use Flauncher.

This became an issue when we wanted to watch 12 Monkeys for free on Youtube Movies, because that is not supported by Smarttube.

Debugging Your TV

So how did I figure out why my Youtube app was hanging? There’s not a lot of good info on this, hence why I wanted to write this article.

First log in to the tv via adb shell. This will allow you to run various commands in order to debug the issue.

Next we’ll want to find the package that is installed for youtube:

BRAVIA_VH2:/ $ pm list packages | grep youtube
package:com.google.android.youtube.tvunplugged
package:com.google.android.youtube.tvkids
package:com.google.android.youtube.tvmusic
package:com.google.android.youtube.tv

The last one looks like the one we want. Now we can just run logcat and get the logs:

BRAVIA_VH2:/ $ logcat com.google.android.youtube.tv

... an endless spew of logs

At this point you can look through the logs and find the relevant info. For me it was:

09-18 16:39:56.044 32372 32372 E AndroidRuntime: Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.google.android.apps.tv.launcherx/com.google.android.apps.tv.launcherx.profile.chooser.ProfileChooserActivity}; have you declared this activity in your AndroidManifest.xml?

Of course, this was not the *actual* problem. The real problem was that I had disabled launcherx and that is something Google does not expect you to ever turn off if you use an Android Tv. Turning it back on via the instructions on Flauncher temporarily fixed the issue.

Hope this was helpful. Despite these issues, I really prefer AndroidTV over the junk from Samsung and Roku, as I actually do have control over these issues without requiring installing a third-party device. Pretty cool!