Android Studio Cannot Find Default Activity
Solution 1:
Give total path of your .MainActivity in Manifest.xml file
<activity android:name="com.example.simpleapp.simpleapp.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android: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".
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"