Android Studio Error: Default Activity not found


Posted on : Fri, 17th Apr 15 09:07 am (Updated on : Fri, 17th Apr 15 09:07 am) GMT
Author : Code2care
Error: Default Activity not found

If you are trying to run an Android Application on a Device or Emulator and you get the above error message (this can occur on both Android Studio and Eclipse IDE) then the most probable reason for this is the missing launcher activity in AndroidManifest.xml file.

Every Android Application must one application tag in Manifest file and within it there must be an Activity with <intent-filter> tag with action and category sub-tags. Which ever activity has these tags within it is the Launcher/Default activity which gets loaded when the App is run on a device.

Note you can have more than once activity with <intent-filter> tags in it, in such a scenario you would find to App launcher icons when the App is installed on the device.

Example :

File : AndroidManifest.xml Language : XML
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.code2care.tools.jsonwithandroid" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/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>

</manifest>
Advertisements



Note that the Activity tag should be inside the <application> </application> tag.


We are operating with limited resources due to COVID-19 - Stay Safe!


We stands in support of racial equality!

Follow us : Facebook - Twitter