0

When I create a new project for android tv using android studio. Got this error

Error while executing: am start -n "com.example.myapplication/com.example.myapplication.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.myapplication/.MainActivity }
Error type 3
Error: Activity class {com.example.myapplication/com.example.myapplication.MainActivity} does not exist.

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

It's using targetSdk and complieSdk as 33. It's a completely new project using android studio without any single change. I clean my gladle cache, and invalid cache and restart, the rebuilt the project after cleaning but it's not getting launched.

2 Answers2

2

If you have previously implemented a custom splash screen in Android 11 or lower, you’ll need to migrate your app to the SplashScreen API to ensure that it displays correctly in Android 12 and higher.

You can follow the steps here mentioned to fix your app launch issue on API 33: Click Here for steps

OR

Might be launcher category issue, Pls check AndroidManifest.xml Here Leanback launcher need to add in your main Activity, i assume you have created emulator for google tv, then add both launcher code. it will work.

<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>
Anant Shah
  • 3,744
  • 1
  • 35
  • 48
  • But i did not use or change a single line of code while creating new project using android studio for android tv. So i did not use any custom splash screen. – Meenakshi Khandelwal Apr 25 '23 at 08:23
  • @MeenakshiKhandelwal I have updated answer, pls check and let me know if it works for you or not. – Anant Shah May 03 '23 at 07:38
  • In my case, adding "android.intent.category.LAUNCHER" not works because no android tv devices open this activity instance of the default one. – Sergio A Jul 26 '23 at 17:20
2

I was getting the same error.

This settings worked for me:

Use of API 33

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

You should check for more details:

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

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