Skip to content Skip to sidebar Skip to footer

Android Studio Cannot Find Default Activity

I've struggled with this for two days now.No matter what I do, Android Studio 2.1.1 , running on windows 10 64 keeps throwing Could not identify launch activity: Default Activity n

Solution 1:

Give total path of your .MainActivity in Manifest.xml file

<activityandroid:name="com.example.simpleapp.simpleapp.MainActivity"><intent-filter><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.LAUNCHER" /></intent-filter></activity>

This based upon:-

Default launcher activity defined here and that will be pointing to android:name tag where MainActivty exist.When ever activity tad does n't found in manifest it will through "Could not identify launch activity: Default Activity not found Error while Launching activity" .User might be changed the package in middle will cause this issue

Solution 2:

OK after many frustrating hours, I discovered that somehow "MainActivity.java" got added as a recognized file type. No idea how, but as the default name for all activities added with Add->New Activity wizard is "MainActivity", android studio always treated "MainActivity.java" as jsp. So every time I added a new activity , it could never find the main activity!

I went to File -> Settings -> Editor -> FileTypes and removed "MainActivity.java" in the right hand pane under "Recognized File Types".

Screenshot showing Recognized File Types box

This fixed the problem. Hope it helps someone else.

Solution 3:

My problem was MainActivity.java not identifying as class.

I went to File -> Settings -> Editor -> FileTypes and removed "MainActivity.java" in the right hand pane under "Recognized File Types".

in my case it was in txt file types.

Solution 4:

The problem could be in the Manifest file. In my case, I did some refactoring that affected the 'activity' tags, (after changing a variable 'activity' into 'mActivity'), that's why it could not find the launcher Activity.

Post a Comment for "Android Studio Cannot Find Default Activity"