Android Studio Build doesn't recognize my MainActivity (Tried all the propositions) - android

I try to run the app in Android Studio but I get an Error: Default Activity not Found, I have come through all the solutions proposed in this question and none of them worked for me so I Set the launch configuration to a Specified Activity as in the picture:
But when I hit Run I get the error Activity not Found in the manifest file :
here is my full Manifest Declaration:

You only need the Activity name inside package
<activity android:name=".MainActivity >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Try create another activity by android studio and check in the lancher home delete in your manifest this intent filter. Maybe this activity has some corrupted and Android studio dont recognize that

Please remove this line
<category android:name="android.intent.category.DEFAULT"/>

Check if your MainActvity extends AppCompactActivity
Or
May be you are using a wrong package name to register activity.
Check both.

Related

Default activity not found Android Studio - repeating error

I've just started having this issue today on a project that has been working for months, without changing the manifest at all I get this error when trying to run the app. My main activity is defined in the manifest as:
<activity
android:name=".MenuActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I've tried all of the solutions I've found from previous questions to unfortunately no effect.
The weirdest part of this is if I hit "sync project with gradle files" 5-10 times one right after the other, it will start working for a few runs and then i'll need to repeat to fix the problem again. Anyone experienced this?
You can edit your configuration as below Edit Configurations:
Then select your Default Activity as below Launch Options:

Error running 'app': Default Activity not found

I do find multiple solutions on here, but non of them work for me...
I cloned an ixisting Androi project, it worked perfectly fine, I added and changed some code, added a fragment and a resource for the fragment. While doing this, everything kept working fine, but suddenly I got this error...
I tried several things:
1. In "Edit Configuration" changed the "Default Activity" to specific activity, but than I get the error that it is not specified in the AndroidManifest.xml (which it is).
2. I tried using the full package path in the manifest ("com.example.something.ActivityLogin" instead of ".ActivityLogin")
<activity android:name=".ActivityLogin"
android:launchMode="singleInstance"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Invalidated caches and restarted
Tried reinstalling Androi Studio
And now for the craziest one:
5. Removed the entire project, pulled the master from git, and the issue is still present!
Also, I did not touch the AndroidManifest nor the ActivityLogin at all, I did not refactor anything...
I'm not sure where to look further, I'm guessing it is an Android Studio (3.2.1 from October 9, 2018) related issue? Also, another project keeps running just fine...
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Build-Clean Project or Build-Rebuild Project
Well, I knew it wasn't my code, it was Android Studio...
This did the trick: https://stackoverflow.com/a/52680053/5427848

Unable to install app using Android Studio

I am working on an app which does not have any launcher activity. But when I try to install that app from Android Studio's Run icon, it says, 'Error running XYZApp: Default Activity not found'
I did not see such issue ever in Eclipse.
Can anyone help to fix this issue? How can I install my app in device which doesn't have any Launcher Activity.
Edit your configuration, and there in 'Launch' select 'Nothing' (or something else, what you want to run)
You must be missing the action and category for your main activity in AndroidManifest file
just add the intent filers in your activity as below :
<activity
android:name="com.example.MainActivity"
android:label="XYZApp"
android:theme="#android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
If you are upgrading from Eclipse to Android Studio you might need to refresh the cache for Android Studio and restart IDE.
Follow the following steps:
File -> Invalidate Caches / Restart...
You also need to mention the Activity in the Manifest file of your Android project. You can use following code to do so: Here MainActivity will start when your app launches on the android device.
<context android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</context>
Run -> Edit Configurations.
On 'Launch' select the activity you want to start.

No Launcher activity found, The launch will only sync the application package on the device

I got this warning from console when running my application on emulator
No Launcher activity found!
The launch will only sync the application package on the device!
In fact i have declared an activity as the main launcer in AndroidManifest.xml file
<activity
android:name=".myActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I don't need any other intent-filter to use on that activity.. just basic main and launcher
What's the reason? Please give me a solution..
If the launcher activity is in another package, you will need to specify that as well.
For instance, from one of my personal projects:
<activity
android:name=".activities.MainScreen"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The MainScreen.java is in the activities package. Also, check spelling for upper or lower case letters.
It seems that you must have "android.intent.action.MAIN" specified immediately before "android.intent.category.LAUNCHER". I encountered the same issue as you when I had the following:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
The issue was resolved only when I re-orderd as follows:
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
In all normal circumstances, listen to what the other guy(s) said.
I was able to replicate your issue using a Mac Book Pro & Eclipse Indigo. when you create your android project, you MUST have Eclipse start you off with a templated activity (like a blank activity). if you don't, and you try to add an activity to your manifest later, Eclipse just derps and can't find the launcher. (i looked at other manifest files and i can't see any differences. i really don't think it's your poor manifest's fault in this special case.)
here's your lazy easy fix:
start a new project, and copy over all the files (make sure you back up ur files first, in case you delete something wrong or mess up the ordering)
Using Eclipse Indigo, open Run Configurations windows, click the project and use launch default activity on Android tab, choose Automatically pick compatible device...and apply.

Android app won't open after i install. But it can run in emulator

I have exported my app from eclipse and installed it on my phone. After installation, I click open from package installer, but the installer force close. Afterwards, when I tried to launch the app, nothing happen after I click it. I click the app in app drawer but it return to home screen instead.
I am able to run in emulator and in debug mode when I connect my device via usb, but not when I export the apk to install.
Note that this is not the first app that I exported to install. Previous apps are working fine.
I found the problem! I had declared the activity 2 times in the manifest with different properties, like:
<activity android:name=".myclass"></activity>
and
<activity android:name=".myclass" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Remove the unwanted one from the manifest and it will work.
Check your android emulator version and the firmware version of the phone. If firmware version is not supported for that app you will be install from adb, but you cant start the app.
Check the settings to be able to install the unknown apps in
Settings->Applications and check box "Unknown Sources"
Try to check on permission in Android Manifest. I was having the same problem earlier when i install a NFC app. I forget to give permission for NFC. After i gave the permission it works fine for me. Please check your AndroidManifest.
I spent few days to identify the problem why it occurred .But I solved my problem this way- Modification in Android Manifest
<activity android:configChanges >
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<I removed my code here that i added for reference to google play store for reference >
Remove the unwanted one from the manifest and it will work.
Try to search errors in your Android manifest, i have the same problem and the problem was the 'R' in the category LAUNCHER are in lower case.
like this:
<category android:name="android.intent.category.LAUNCHEr" />
to solve it, simple:
<category android:name="android.intent.category.LAUNCHER" />
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Removing the configuration of all the modules that are not from the app worked for me. In other words, just leave the Project.app module and check its configuration.
Edit Run/Debug Configurations -> Android app -> app
GL
if you use splash in react native:
To avoid error: Binary XML file line #XXX: requires a valid src attribute
inside a layer-list, use:
<item android:drawable="#drawable/image" />
instead of:
<item>
<bitmap android:src="#drawable/image"/>
</item>
My solution is to add this flag in download manager when application is install
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
In my case - i had this flag -> intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
I replaced it with Intent.FLAG_ACTIVITY_NEW_TASK and everything worked!
My Manifest looked like this. Those that need help and have a similar manifest look bellow.
<activity android:name=".login.activities.SplashScreenActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="example.com"
android:scheme="https"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
You just need to remove the
< data>
element in the intent-filler and it should work.

Categories

Resources