Geek96
Geek96

Reputation: 57

Default Activity Not Found Error Android Studio

I am having trouble launching my app since it gives me the Default Activity not Found error. I have read other threads and have tried adding/changing the position of the following code:

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

but it still does not work. I have also tried

File -> Invalidate Caches / Restart...

and still does not work. Below is my Android Manifest.xml file. I would like to start my app with the activity named ".Main2Activity". Also note that for some reason my .xml files in Design mode appear with a black background and weirdly different.

<?xml version="1.0" encoding="utf-8"?>

<!--
     The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
     Google Maps Android API v2, but you must specify either coarse or fine
     location permissions for the 'MyLocation' functionality. 
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-feature
        android:name="android.hardware.camera"
        android:required="true" />

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


    <activity android:name=".Dining" />
    <activity android:name=".SignUp" />

    <provider
        android:name="android.s


        upport.v4.content.FileProvider"
        android:authorities="com.example.android.fileprovider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@layout/file_paths" />
    </provider>
    <!--
         The API key for Google Maps-based APIs is defined as a string resource.
         (See the file "res/values/google_maps_api.xml").
         Note that the API key is linked to the encryption key used to sign the APK.
         You need a different API key for each encryption key, including the release key that is used to
         sign the APK for publishing.
         You can define the keys for the debug and release targets in src/debug/ and src/release/. 
    -->
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="AIzaSyD37TQWZ02Re5_3lTH-kL17cOOVQw1B8dY" />

    <activity>
        android:name=".MapsActivity"
        android:label="@string/title_activity_maps" />


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

    <activity android:name=".MapsMain"></activity>
</application>

Upvotes: 2

Views: 479

Answers (2)

A. Petrizza
A. Petrizza

Reputation: 3350

Have you tried this: https://stackoverflow.com/a/22028681/1101730.

Add these lines to the build.gradle file inside the android { ... } block:

android { ... sourceSets { main.java.srcDirs += 'src/main/' } }

After editing the file, click Tools > Android > Sync Project with Gradle Files.

Last thing I can think of is to click on Run > Edit configuration and make sure that your activity is selected to be the launching activity.

Upvotes: 0

Tuhin Subhra
Tuhin Subhra

Reputation: 356

<activity>
        android:name=".MapsActivity"
        android:label="@string/title_activity_maps" />

check, You must have error in xml for that. It'll be :

<activity
        android:name=".MapsActivity"
        android:label="@string/title_activity_maps" />

isn't it?

Upvotes: 2

Related Questions