Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio Default Activity not found

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.

like image 795
Андрей Б Avatar asked Aug 04 '17 13:08

Андрей Б


People also ask

How do I determine the default activity using Android Studio?

In Android, you can configure the starting activity (default activity) of your application via following “intent-filter” in “AndroidManifest. xml“. See following code snippet to configure a activity class “logoActivity” as the default activity.

What is default activity not found?

However, that error: "Default Activity Not Found" seems to be telling you that you don't have an activity declared in file AndroidManifest. xml that is marked as the main activity, to be launched when the application starts.

Is your project missing an Android AndroidManifest XML?

Well, do you have an AndroidManifest. xml file within your project? Try: Click on your project -> Refresh (F5) -> Go to "Project" in the menu bar -> Clean (and clean the project). If all else fails, restart eclipse.

What is Activity_main XML in Android Studio?

The Main Activity File activity_main refers to the activity_main. xml file located in the res/layout folder. The onCreate() method is one of many methods that are figured when an activity is loaded.

How to turn off activity in Android Studio?

In Android Studio under Run/Debug Configuration -> Android Application -> General -> Activity -> select the option "Do not launch Activity". This is the solution when the project is a service, or has no default activity for some other reason. Nothing in the previous answers helped me.

Why does my Android app say default activity not found?

However, that error: "Default Activity Not Found" seems to be telling you that you don't have an activity declared in file AndroidManifest.xml that is marked as the main activity, to be launched when the application starts. You should have at least one activity that looks something like this:

Is there a default activity in the Android Studio manifest?

I actually had a Default Activity in the Manifest, but for some reason Android Studio didn't find that. If you are working on a widget app, this solution should work for you: This is just skip the problem, but it doesnt fix it. The app wont run at the end of build after set to nothing I did this.

Why is my Android launcher activity not found?

⚠️ Error: Default Activity not found If you are trying to run an Android Application on a Device or Emulator and you get the above error message (this can occur on both Android Studio and Eclipse IDE) then the most probable reason for this is the missing launcher activity in AndroidManifest.xml file.


Video Answer


2 Answers

This <app is supposed to be <application you specify your custom app in here:

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

Check the documentation the name section says:

The fully qualified name of an Application subclass implemented for the application. When the application process is started, this class is instantiated before any of the application's components. The subclass is optional; most applications won't need one. In the absence of a subclass, Android uses an instance of the base Application class.

Full 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>
like image 145
Matias Olocco Avatar answered Oct 17 '22 09:10

Matias Olocco


Solved by clicking the "Sync project with gradle files"

like image 4
Polycarp Kavoo Avatar answered Oct 17 '22 07:10

Polycarp Kavoo