Missing MainActivity Error when running on Android TV Emulator - android

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.

Related

I can not see hello world app in Android Studio

Hi I have installed Android studio correctly. I made AVD for e.q Marshmallow and project on the same platform. after press RUN, AVD turns on. I can do everything on emulated android phone(other issue- after running this my computer dramticly slowing down) but I should see my "Hello world" app, there is not there. I'm getting following error
Unexpected error while executing: am start -n "com.example.zad2/com.example.zad2.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while Launching activity
where zad2 is my project name.
On Stacfoverflow i saw tips to add into manifest some filter code but I already have it:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.Zad2">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Yea don't trouble friends. I found this post: Session 'app': Error Launching activity
and I unistalled my app from AVD :)

Android Studio launches wrong Activity when merging AndroidManifest from ProductFlavorBuildType hybrid directory

I'm using Android Studio 2.1.3 (Mac OS X) and com.android.tools.build:gradle:2.1.3. I've already tried invalidating cache and restarting and clean builds.
I have a project with many ProductFlavors, all of which use the same starting activity save one (this one is a paid version that uses the licensing library, all the others are free so I don't bother, although a solution might just be to use the licensed version of the activity for all flavors but skip the licensing unless a resource is set... just seems too easy to hack). I thus have 2 AndroidManifest.xml files:
// app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.app">
...
<application android:allowBackup="true" android:icon="#mipmap/ic_launcher"
android:label="#string/appFriendlyName"
android:theme="#style/AppTheme">
<activity
android:name="com.company.app.TabsFragmentActivity"
android:screenOrientation="portrait"
android:label="#string/appFriendlyName">
<intent-filter android:label="#string/launcherLabel">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
</application>
</manifest>
// app/src/PaidFlavor/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.company.app">
<application android:allowBackup="true" android:icon="#mipmap/ic_launcher"
android:label="#string/appFriendlyName"
android:theme="#style/AppTheme">
<activity
tools:node="merge"
android:name="com.company.app.TabsFragmentActivityLicensed"
android:screenOrientation="portrait"
android:label="#string/appFriendlyName">
<intent-filter android:label="#string/launcherLabel">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
tools:node="remove"
android:name="com.company.app.TabsFragmentActivity"/>
</application>
</manifest>
This works great, and I can inspect the generated intermediate (merged) AndroidManifest.xml, and indeed the TabsFragmentActivity activity is removed, and the TabsFragmentActivityLicensed is added, and all is right with the world.
But I don't want the debug version (build type) to be licensed. Again, I can work around it easy enough in code, but it's the principle of the matter! So I thought it would be easy to just move
app/src/PaidFlavor/AndroidManifest.xml
to
app/src/PaidFlavorRelease/AndroidManifest.xml
This is where things go wrong. Everything builds without error, and I look at the intermediate (merged) manifest and it still looks correct. However, Android Studio tries to launch the PaidFlavor with release build type as:
adb shell am start -n "com.company.project/com.company.app.TabsFragmentActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Wrong activity! Where's it getting it from? Am I using the wrong subdirectory (PaidFlavorRelease/)? This results in the obvious error:
Error while executing: am start -n "com.company.project/com.company.app.TabsFragmentActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.company.project/com.company.app.TabsFragmentActivity }
Error type 3
Error: Activity class {com.company.project/com.company.app.TabsFragmentActivity} does not exist.
Error while Launching activity

LAUNCHER open: Permission denied

Testing Navigation Drawer with Material Design App. When I run the app in Android Studio, I got the following error. App is installed in my phone but could launch. Please let me know what permission I am missing to add.
Launching application: com.jobsclipper.jobs/com.jobsclipper.jobs.MainActivity.
DEVICE SHELL COMMAND: am start -n
"com.jobsclipper.jobs/com.jobsclipper.jobs.MainActivity" -a
android.intent.action.MAIN -c android.intent.category.LAUNCHER open:
Permission denied open: Permission denied Starting: Intent {
act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
cmp=com.jobsclipper.jobs/.MainActivity }
Here is My manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jobsclipper.jobs"
android:versionCode="1"
android:versionName="1.0" >
<!-- for most things, including card.io & paypal -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

Failure [INSTALL_FAILED_INVALID_APK] on building and deploying android studio project

I'm developing an android application on Android Studio, it was working fine but recently it has been throwing the following error. Any ideas on how i can solve it?
EDIT: Usually after about ten tries it deploys
Waiting for device.
Target device: samsung-gt_p5100-c1607e2b52fa88f
Uploading file
local path: C:\Users\Yohannes\IdeaProjects\PaymentAssistant\out\production\PaymentAssistant\PaymentAssistant.apk
remote path: /data/local/tmp/tamru.yohannes.PaymentAssistant
Installing tamru.yohannes.PaymentAssistant
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/tamru.yohannes.PaymentAssistant"
pkg: /data/local/tmp/tamru.yohannes.PaymentAssistant
Failure [INSTALL_FAILED_INVALID_APK]
LogCat:
12-05 13:36:25.193 8332-8332/? E/cutils-traceļ¹• Error opening trace file: No such file or directory (2)
Manifest File
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="tamru.yohannes.PaymentAssistant"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:targetSdkVersion="15"
android:minSdkVersion="14"
tools:ignore="OldTargetApi" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application
android:label="#string/app_name"
android:icon="#drawable/assistant"
android:allowBackup="false"
android:allowClearUserData="true"
android:debuggable="true"
android:hardwareAccelerated="true"
android:theme="#android:style/Theme.DeviceDefault.Light">
<activity
android:name="tamru.yohannes.PaymentAssistant.main.Main"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="tamru.yohannes.PaymentAssistant.main.OCRCamera">
<intent-filter>
<action android:name="android.intent.action.OCRCamera"/>
</intent-filter>
</activity>
<activity
android:name="tamru.yohannes.PaymentAssistant.main.About"
android:label="#string/about" />
<activity
android:name="tamru.yohannes.PaymentAssistant.main.Preferences"
android:label="Preference" >
<intent-filter>
<action android:name="android.intent.action.Preferences"/>
<category android:name="android.intent.category.PREFERENCE"/>
</intent-filter>
</activity>
<activity
android:name="tamru.yohannes.PaymentAssistant.main.Transfer"
android:theme="#android:style/Theme.Holo.Dialog.NoActionBar" />
<activity
android:name="tamru.yohannes.PaymentAssistant.main.UserActions"
android:theme="#android:style/Theme.DeviceDefault.Light.Dialog.NoActionBar" />
</application>
</manifest>
In my case (i have a rooted device) and when i rooted, something happened with my permission of /data/local/tmp and they have been changed, so adb can't get access temp file. How i solved:
1. Install RootExplorer
2. Create new "tmp" folder on sdcard
3. Long press on tmp folder, and select Link to this folder (last option in menu)
3. Go to /data/local/ and tap button CREATE LINK from bottom
Please change your package name to be all lower case in your manifest and make sure your android:name attributes for your activities reflect the changes.
Go to "Build" > "Clean Project". Works for me.

Android Emulator not Displaying output

I'm new just working with some basic Android codes. My problem is that Android Emulator is not showing any output when I run code. It takes really long and on console it sticks here
[2013-03-31 03:17:55 - Helloworld] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.helloworld/.MainActivity }
and emulator looks like this
I have waited for 5-10 minutes but it does not show output. Please guide me where the problem might be. I downloaded sdk ADT Bundle for Windows and configured it as mentioned in official site.
In Eclipse, try :
Window -> Show View -> Other -> Android/Devices
Select the Emulator from the newly added Devices window, and check back your logcat.
I'd try a little debug, and set a break point on the very first line of code in your app's main activity. Then I'd step thru and see where it breaks.
I've just encountered the similar problem, in my case I forgot to add the activity in AndroidManifest.xml file.
The following is my Manifest file for example ...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testalarm"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="10" />
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.testalarm.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.testalarm.CheckpointActivity" >
<intent-filter>
<action android:name="com.example.testalarm.CheckpointActivity" />
</intent-filter>
</activity>
</application>
</manifest>
Check if you have all required activities as <activity> under <application>

Categories

Resources