0

after the recent update, my application will not run. This is what happens whenever I run the app:

14:42   Gradle sync started

14:42   Project setup started

14:42   Gradle sync finished in 2s 996ms (from cached state)

14:42   Error running 'app': Default Activity not found

I tried most of the known methods and searched online which did not help. I have even invalidated the caches to see if there were any indexing issues. Some of the files I deleted were restored to see if that may have caused the problem but it did not.

This is the current state of my manifest:

    <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

<meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="AIzaSyC60Yz2nx7GlbBMJqm69j_dZCuV_ULUIB0"/>

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <activity android:name=".MapActivity"/>

</application>

Please leave your suggestions below. Your help is appreciated!

Kenneth
  • 39
  • 8

2 Answers2

1

Change your tag for this one:

  <activity android:name=".MainActivity">
     <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
     </intent-filter>
  </activity>
DeadCoon
  • 81
  • 4
0

There are a couple of possible solutions:

Option one:

File> Invalidate cache and Restart

Option two:

Check whether any of the activity tags in your manifest has a launcher intent-filter. This is what indicates that an activity is a default activity. An launcher intent filter looks like this:

<intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

Just add it inside the activity tag of whichever activity you want to make your default activity.

Option three (for older versions of Android studio):

In your Android Studio, right click on your project and choose Open Module Settings. Navigate to the Sources tab, find the src folder, right click on it and mark it as "Sources".

EDIT:

Option three (for newer versions of Android studio):

Option 2 would not work for newer versions of Android studio because the sources tab does not exist. You can still add the src folder manually by adding it to your build.gradle file. You can use this as a guide.

Taslim Oseni
  • 6,086
  • 10
  • 44
  • 69
  • There is no 'Sources tab' when you open the project module. The tabs currently listed are 'properties,' 'signing,' 'flavours,' 'build types' and 'dependencies'. Other than that, there is another option listed under the first tab: 'source compatibility'. – Kenneth Jul 31 '18 at 11:35
  • My bad @Kenneth.. The sources tab does not exist for newer versions of Android studio. I have updated my answer accordingly. Sorry for the initial confusion. – Taslim Oseni Jul 31 '18 at 12:54