Android studio Default Activity not found

Viewed 9143

After i have created my own appplication class:

package com.example.bezzabarovaa.myapplication;
import android.app.Application;
import android.content.Context;

/**
 * Created by bezzabarovaa on 04.08.2017.
 */

public class app extends Application {
public static Context context;

@Override public void onCreate() {
    super.onCreate();
    context = getApplicationContext();
}

}

and have changed manifest.xml (changed application to app class)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.bezzabarovaa.myapplication">

<app
    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">
    <activity android:name=".MainActivity"
        android:label = "@string/app_name">

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

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

I`ve got a message Error running Unnamed: Default Activity not found

If I will change my classapp back to application in manifest.xml - everything is ok. Where is a problem? Thank you.

8 Answers

Solved by clicking the "Sync project with gradle files"

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.bluetoothlegatt">

    <uses-feature
        android:name="android.hardware.bluetooth_le"
        android:required="false" />

    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <application
        android:icon="@drawable/app_icon"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Holo.Light">
        <activity
            android:name="com.example.android.bluetoothlegatt.DeviceScanActivity"
            android:icon="@drawable/app_icon"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.example.android.bluetoothlegatt.DeviceControlActivity" />

        <service android:name="com.example.android.bluetoothlegatt.BluetoothLeService" />
    </application>

</manifest>

I solved the very same issue by following steps

Close Android Studio

deleting from :

C:\Users\your user name.android/log and gradle folder

C:\Users\your user name.gradle

from C:\Users[your user name]

Restart Computer and run Android studio (it Will take some time to rebuild)

Related