Thursday 25 May 2017

Error: Default Activity Not Found

Whenever we run the android studio project on startup we get the the error running app: Default activity not found

This is resolved by doing this:

1. Go to AndroidManifest.xml file (press shift twice and enter the file name to search it in android studio)

2. Add this code:

<activity    android:name="com.your.package.name.YourActivity"    android:label="@string/app_name">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

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

3. Go build.gradle add this code
sourceSets {
    main.java.srcDirs += 'src/main/<YOUR DIRECTORY>'}
Another easy way to solve the issue is:
When you import the android project use the steps below:
1. Download the git package using download zip
2. In android studio use Import from git
3. Direct to the directory where your project is saved and select the project folder
4. In the next step use import using manual gradle steps
5. Select empty Activity
6. Once it imports go to file>New>project
7. It will sync the project and make it an android project showing up gradle files in the 
   android select view.

No comments:

Post a Comment