2

I created a sample Android TV app for testing purposes. I followed the documentation at

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

This is how my manifest file looks like:


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="android.permission.INTERNET" />

    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false" />
    <uses-feature
        android:name="android.software.leanback"
        android:required="true" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.CourseViewer">
        <activity
            android:name=".MainActivity"
            android:banner="@drawable/app_icon_your_company"
            android:exported="true"
            android:icon="@drawable/app_icon_your_company"
            android:label="@string/title_activity_main"
            android:logo="@drawable/app_icon_your_company"
            android:screenOrientation="landscape">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".DetailsActivity"
            android:exported="false" />
        <activity
            android:name=".PlaybackActivity"
            android:exported="false" />
        <activity
            android:name=".BrowseErrorActivity"
            android:exported="false" />
    </application>

</manifest> 

This is what I get when I run the app on an android tv emulator. Can someone please let me know what is missing in the manifest file? I do have the MainActivity and the manifest looks fine to me.

02/20 11:38:56: Launching 'app' on Android TV (4K) API 33.
Install successfully finished in 824 ms.
$ adb shell am start -n "edu.app.courseviewer/edu.app.courseviewer.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while executing: am start -n "edu.app.courseviewer/edu.app.courseviewer.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=edu.app.courseviewer/.MainActivity }
Error type 3
Error: Activity class {edu.app.courseviewer/edu.app.courseviewer.MainActivity} does not exist.

Error while Launching activity
Failed to launch an application on all devices

I have tried restarting android studio, invalidating caches and restart, synced gradle files. I was hoping the app would start on Android TV emulator.

karu6500
  • 45
  • 4

4 Answers4

3

It seems that Android Studio is using category android.intent.category.LAUNCHER for starting your MainActivity, so you can fix your problem by adding <category android:name="android.intent.category.LAUNCHER" /> in yout manifest for your MainActivity.

mahdi
  • 598
  • 5
  • 22
  • THIS WORKS! Have been looking for an answer for hours now. Not even the stock generated TV app in Android Studio launches without this. – Isak Apr 16 '23 at 14:01
0

I was getting the same error. In the new usage, it is necessary to use the for the first page as mentioned.

Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=edu.app.courseviewer/.MainActivity }

Use of API 33

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

Use of API 32, 31 etc.

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

You can check for detailed information:

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

Halil Ozel
  • 2,482
  • 3
  • 17
  • 32
0

I'm using

<activity
    android:name="com.example.myapplication.MainActivity"    
    android:label="@string/app_name" >    
    <intent-filter>    
        <action android:name="android.intent.action.MAIN" />    
        <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
        <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter>    
</activity>

and it's working for All APIs and Google tv and Android TV as well

Anant Shah
  • 3,744
  • 1
  • 35
  • 48
0

I was getting the same error.

I tried to add android.intent.category.LAUNCHER to the android tv activity declaration with bad result for my users: They started Android TV version in android devices!

After few tests I suspect that the error is in Android Studio. We consider our solution as not definitive but, until now, is the only that works for us:

  1. Declare the Android devices activity as LAUNCHER and the Android TV activity as LEANBACK_LAUNCHER (as Google explains in its documentation).
  2. Click the Debug button in Android Studio to test your Android TV version in one Android TV device or emulator. You'll receive a missing activity error. Don't worry, the app has been installed in the Android TV device.
  3. Go to your Android TV device and run the app.
  4. Click the button "Attach Debugger" in Android Studio.

Following these steps you'll be able to run and debug your Android TV app version as you were doing until now.

Sergio A
  • 71
  • 2
  • 3
  • hi @Sergio A could you help me over here -> https://stackoverflow.com/questions/76786965/facing-issue-while-validating-amongst-the-edittexts-in-recyclerview – android dev Jul 28 '23 at 11:09