Android studio Not working Activity not found

After I created my own application 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 changed manifest.xml (changed app 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 have a message Startup Error Unnamed: Default Activity not found

If I change my class app

to application

in manifest.xml everything is fine. Where is the problem? Thank.

+5


source to share


8 answers


This one <app

should be <application

where you point your custom app here:

<application android:name=".app" ...

      

Check the documentation under the names section:



The fully qualified name of the Application subclass as implemented for the application. When the application process is started, this class is created by some of the application components. the subclass is optional; most applications will not need this. In the absence of a subclass, Android uses an instance of the base class Application.

Complete example (with your code):

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

<application
    android:name=".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>
</application>
</manifest>

      

+8


source


use below code snippet

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

<application
    android:name=".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" />

        </intent-filter>
    </activity>
</application>

      



Hope this helps you.

+2


source


I ran into the same problem a while ago by changing my default activity to a different one.

The solution was to invalidate the caches and restart Android Studio:

File -> Invalidate Caches / Restart...

and then press Invalidate and Restart

.

+1


source


Add below line to your app manifest tag

<application
    android:name=".app"
    ...
     </application>

      

0


source


You can make Android Studio not complain by going to the Edit Configurations menu (tap Shift three times, type Edit Configurations), then change Launch Options> Launch to Nothing.

I will probably add a general instruction containing instructions to avoid confusion.

0


source


Solved by clicking "Synchronize project with Gradle files"

0


source


<?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>

      

-1


source


I solved the same problem by following these steps

Close Android Studio

removing from:

C: \ Users \ your username. Android / log and Gradle folder

C: \ Users \ your username. Gradle

from C: \ Users [your username]

Restart your computer and launch Android Studio (it will take some time to recover)

-1


source







All Articles