How to export game for Android TV?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By giga

Hi everyone

I have made a simple Godot game and exported it for Android. The app runs fine on the phone and on the Android TV. Alas, on Android TV it will not show in the list of apps, since it is not a native Android TV app I assume.

I know there are workarounds, like sideloading or making an Android TV native apk that will launch it, but I would rather just export it properly.

Is there a way to do this from Godot? Maybe a custom template build? I have practically zero Android dev experience.

edit:
I believe what needs to be done is use the custom build.

My understanding is that I need to add this activity to the manifest

<intent-filter>
  <action android:name="android.intent.action.MAIN" />
  <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>

As described here: link

I did not chage the manifest, wanted to try building it as-is first.

This is what I have done so far:

  • I have made sure to have openjdk-8. Removed openjdk-11 completely.
  • Checked Export template Manager for the matching version of the templates (redownloaded just in case - 3.2.3.stable installed)
  • ‘Project > Install Android Build Template…’ - removed android dir and re-added like this
  • ‘Editor>Settings>Export>Android’ - since non-custom build works, I just added SDK location /home/user/Adnroid/Sdk’, as mentioned in the guide.
  • ‘Project>Export’ - checked ‘Custom Template>Use Custom Build’ On

Now export project returns:

JAVA_HOME not set and no ‘java’ command could be found in your PATH.

Which is strange, cause java is on the path - e.g. java -version works. But fine, I just add path and then behold:

Exit Code: 1

This is where I am stuck now.

:bust_in_silhouette: Reply From: giga

The problem was with the Godot installation. The software manager installed it with flatpak. Since flatpak snadboxes the app, access to java was not possible by default. One way to resolve the issue is to allow access to the needed locations. But much simpler approach is to download the Godot binary from the Godot homepage and just run it like that.

The intution about changing the manifest is accurate, in the intent filter this is the part that needs to be replaced (for further tweaking one can consult the docs):

<category android:name="android.intent.category.LEANBACK_LAUNCHER" />

After this everything ran smoothly.

How to connect Ola with the Android…?