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) UTC
Author : Code2care
100+ votes
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.

Code2care's mission is to share varied knowledge in technical and non-technical areas gathered during day-to-day learnings and development activities so that our visitors can leverage this portal to find solutions to their queries without re-inventing the wheel. Technical posts include Learnings, Tutorials, Video Tutorials, Code Snippets, Tips-n-tricks.

Follow us : Facebook - Twitter - Google +