Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not identify launch Activity: Default Activity not found

I'm new to android and I have encounterded a problem. The console said that "Could not identify launch activity: Default Activity not found". I have add

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

in manifests. And I have tried Invalidate caches/Restart,still not worked. And the class file which contains the main activity turn green in android studio. I don't know what that means. This is my manifests file.

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.mrrobot.mycoolweather" > <uses-permission android:name="android.permission.INTERNET"/>  <application     android:allowBackup="true"     android:icon="@mipmap/ic_launcher"     android:label="@string/app_name"     android:supportsRtl="true"     android:theme="@style/AppTheme" >     <Activity       android:name="com.example.mrrobot.mycoolweather.activity.ChooseAreaActivity"         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>  </manifest> 

The chooseAreaActivity is the one I want to use as launcher activity. enter image description here

like image 597
Jiawei Yang Avatar asked Nov 22 '15 13:11

Jiawei Yang


People also ask

What is default activity not found?

However, that error: "Default Activity Not Found" seems to be telling you that you don't have an activity declared in file AndroidManifest. xml that is marked as the main activity, to be launched when the application starts.

How do I make activity default activity?

In Android, you can configure the starting activity (default activity) of your application via following “intent-filter” in “AndroidManifest. xml“. See following code snippet to configure a activity class “logoActivity” as the default activity.

What happens if by mistake you have two activities with launcher intent in manifest file?

On latest Android versions - If there are more than one launcher activities and if we don't put this category tag then the activity which is mentioned first in the Android manifest file will get launched as start-up activity.


2 Answers

For main activity in your manifest you have to add this with category LAUNCHER (First Activity on launch app):

<activity     android:name=".MainActivity"     android:label="YourAppName"     android:theme="@style/AppTheme.NoActionBar" >       <intent-filter>             <action android:name="android.intent.action.MAIN" />              <category android:name="android.intent.category.LAUNCHER" />       </intent-filter> </activity> 

For other activity you have to change category to DEFAULT:

<activity     android:name=".OtherActivity"     android:theme="@style/AppTheme.NoActionBar" >     <intent-filter>             <action android:name="package.OtherActivity" />              <category android:name="android.intent.category.DEFAULT" />     </intent-filter> </activity> 

Check this Activity and this Start Another Activity

So your code is:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.mrrobot.mycoolweather" > <uses-permission android:name="android.permission.INTERNET"/>  <application     android:allowBackup="true"     android:icon="@mipmap/ic_launcher"     android:label="@string/app_name"     android:supportsRtl="true"     android:theme="@style/AppTheme" >      <activity         android:name=".activity.ChooseAreaActivity"         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>  </manifest> 
like image 174
Michele Lacorte Avatar answered Sep 23 '22 06:09

Michele Lacorte


Sometimes it is solved just restarting Android Studio

Click on "File" and then "Invalidate Cache"


I had the "Default Activity not found" problem a couple of times and I could solved restarting my android Studio.

like image 25
Orlando Herrera Avatar answered Sep 22 '22 06:09

Orlando Herrera