Android name mainactivity ошибка

I am getting an error which reads The activity ‘MainActivity’ is not declared in AndroidManifest.xml

Screenshot of the error

What is the problem here?

Robin Daugherty's user avatar

asked Oct 21, 2016 at 18:57

Jodhvir Singh's user avatar

6

I got this error when moving a lot of files, to fix just resync your gradle files.

File->Sync Project with Gradle Files

answered Mar 20, 2019 at 17:40

MRDJR97's user avatar

MRDJR97MRDJR97

8082 gold badges10 silver badges26 bronze badges

1

Try to go to File->Invalidate Caches / Restart and choose invalidate and restart ,it worked for me

df778899's user avatar

df778899

10.6k1 gold badge24 silver badges35 bronze badges

answered Dec 17, 2018 at 17:59

Lucian Gabriel's user avatar

Sometimes when moving or renaming files, you can have broken XML files. My case that the ic_launcher.xml was corrupt. I regenerated that and worked just fine.

Check every XML in your proyect.

answered Nov 29, 2018 at 23:10

Mariano L's user avatar

Mariano LMariano L

1,7793 gold badges28 silver badges49 bronze badges

You are most likely just missing the below from your AndroidManifest:

<activity
    android:name=".MainActivity"
    android:label="@string/app_name"

Here is a full example of an AndroidManifest:

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

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
    <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>
</manifest>

answered Oct 21, 2016 at 19:05

Prad's user avatar

PradPrad

5157 silver badges15 bronze badges

3

this happened for me when my laptop suddenly shut down when working with project. if you see your activity declaration in your manifest, do not open any xml files. they maybe broken and corrupt after opening files.
so do these steps:

  1. delete all .iml files from your project
  2. go to Files => invalidate cache / Restart
  3. Rebuild your project gradle
  4. finally if problem still exists, go to Files => Sync project with gradle files

https://stacklearn.ir

answered Aug 26, 2019 at 14:25

Hossein Karami's user avatar

This can be only two reason,

the bold one, missing extend statement

class MainActvity extends AppCompatActivity 

or

you are using a wrong package name to register your activity so just in this case use ALT+Space then studio will show the options itself.

Andre Batista's user avatar

answered Oct 21, 2016 at 19:00

Pavneet_Singh's user avatar

Pavneet_SinghPavneet_Singh

36.7k5 gold badges53 silver badges68 bronze badges

All of my XML file were cut in half for some reason, I’m not sure when it happened (I use Git VCS, so maybe that). I had to go through each of them and restore the code.

answered Apr 11, 2019 at 9:06

sp00ky's user avatar

sp00kysp00ky

1519 bronze badges

1

It have three ways to resolve

1:-
Go File->Invalidate Caches / choose invalidate and restart ,it works

2:-
If you make MainActivity make sure you have onCreate method in it and extend with AppCompatActivity .

3:- And last option sync project with Gradle file

answered Apr 11, 2019 at 9:11

Ahmad's user avatar

AhmadAhmad

2012 silver badges12 bronze badges

Follow these steps:

  1. File => Invalidate Caches / Restart…
  2. Files => Sync project with gradle files

If the steps above don’t work, write:

com.example.(project name).MainActivity

It should work, worked for me.

N'Bayramberdiyev's user avatar

answered Mar 19, 2020 at 10:01

Shahriar Prottoy's user avatar

For those cases the you recently changed the android:allowBackup settings, make sure you also set the tools:replace="android:allowBackup" in case some of your dependency have it declared in them to override it. I wouldn’t know this solution until I manually execute Gradle > app > cleanbuild > lintFix

The exact error I received was:

Error: Attribute application@allowBackup value=(false) from AndroidManifest.xml:41:9-36
is also present at [com.kaopiz:kprogresshud:1.2.0] AndroidManifest.xml:12:9-35 value=(true).
Suggestion: add ‘tools:replace=»android:allowBackup»‘ to element at AndroidManifest.xml:39:5-254:19 to override.

answered Jul 27, 2020 at 8:26

mr5's user avatar

mr5mr5

3,4023 gold badges40 silver badges57 bronze badges

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

    <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/Theme.YOURPAKAGE">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

NOTE:
Replace your AndroidManifest.xml file code with the above code and you just have to change the name of your package at those places where I have mentioned (YOURPAKAGE) hopefully the problem will be solved

m4n0's user avatar

m4n0

29.3k26 gold badges75 silver badges89 bronze badges

answered Oct 4, 2021 at 13:12

Nadir Hussain's user avatar

2

replace in your AndroidManifest.xml

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

answered Oct 21, 2016 at 19:03

meladandroid's user avatar

1

You should try this

<activity
            android:name="com.example.stockquote.StockInfoActivity"
            android:label="@string/app_name"
             />

For more detail you can check hereActivity declare

Community's user avatar

answered Oct 21, 2016 at 19:09

Aby Nav's user avatar

Thanks everyone for taking the time out to help a beginner.
I found out that I had somehow misspelled the Package in MainActivity.java
When I corrected it the error was gone.
Thank you all.

answered Oct 22, 2016 at 7:15

Jodhvir Singh's user avatar

Jodhvir SinghJodhvir Singh

3451 gold badge3 silver badges11 bronze badges

I was getting an error «The activity ‘MainActivity’ is not declared in AndroidManifest.xml», even though it was correct in the manifest file.

My problem was that when I created the project I had to mark the item «Use AndroidX artifacts».

answered Feb 24, 2019 at 10:02

Kseniya's user avatar

1

If you see that error occur after upgrading versions of IntelliJ IDEA or Android Studio, or after Generating a new APK, you may need to refresh the IDE’s cache.

File -> Invalidate Caches / Restart...

answered Mar 27, 2019 at 5:54

Zubair's user avatar

ZubairZubair

311 silver badge9 bronze badges

I was working on my project suddenly my laptop restarts i tried lot of methods but i was not able to fix it.
But at the end i did it
do these steps and let me know it is working or not?

1. File > Invalidate Cache and restart the the android studio
2. Build > Clean Project and then Rebuild project
3. Sync project with gradle files

if it is still showing you error try these steps

1. Create new activity
   Remember to clink on checkBox Launcher Activity
   Hope this will Fix your problem

In the end go to AndroidManifest.xml and change New activity Default to previous activity

answered Jan 9, 2020 at 11:50

zinonX's user avatar

zinonXzinonX

3302 silver badges20 bronze badges

In my case, none of the answers helped. Luckily, I remembered that I added a variable in build.gradle, which I tried to access from MainActivity.

Problem was that this new variable wasn’t present in AndroidManifest.xml. Once I added the variable to AndroidManifest.xml, the problem was solved.

answered Sep 8, 2020 at 6:39

domaci_a_nas's user avatar

This is an odd one. For me I had to open Edit Configurations (run configuration) and select <no module> under the Module drop-down. Then reselect my project under the Module drop-down and Apply. It the built and ran just fine.

answered Aug 9, 2021 at 20:30

Had the same problem with a project which I just downloaded the starter code for
an app , everything looked fine in the AndroidManifest.xml , I just deleted the com.example.android.(yourappname).MainActivity and wrote .dMainActivity and it worked.

answered Aug 26, 2022 at 3:46

Xolot's user avatar

XolotXolot

132 bronze badges

I encountered a problem while using Android Studio. When I’m trying to run any app, I get the same error «Default activity not found», and in my code in line tools:context=".MainActivity", MainActivity is highlighted red and it says «Unresolved class MainActivity». It happens even if I create a brand new «empty activity».

So far I’ve tried:

  • refreshing IDE cache
  • checked package names in Android manifest and MainActivity
  • selecting a default activity in-app configuration
  • made sure that src is the source directory

I’ve also noticed that in my «most advanced» app the build.gradle looks like this:

Screenshot

Android manifest:

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

    <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">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

Project directory + code:

dir

activity main xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ImageView
        android:id="@+id/coffee_grains"
        android:layout_width="match_parent"
        android:layout_height="300sp"
        android:contentDescription="Coffee Grains"
        android:scaleType="centerCrop"
        android:src="@drawable/coffee_grains"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/cup"
        android:layout_width="120sp"
        android:layout_height="170sp"
        android:layout_marginLeft="8dp"
        android:src="@drawable/cup"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toBottomOf="@id/coffee_grains" />

    <TextView
        android:id="@+id/quantity"
        android:layout_width="100sp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16sp"
        android:layout_marginTop="16sp"
        android:gravity="center"
        android:text="quantity"
        android:textAllCaps="true"
        android:textSize="16sp"
        app:layout_constraintLeft_toRightOf="@id/cup"
        app:layout_constraintTop_toBottomOf="@id/coffee_grains" />

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintLeft_toRightOf="@id/cup"
        app:layout_constraintTop_toBottomOf="@id/quantity">

        <Button
            android:id="@+id/plus"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_marginLeft="8dp"
            android:onClick="increment"
            android:text="+" />

        <TextView
            android:id="@+id/quantity_text_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8sp"
            android:layout_marginRight="8sp"
            android:gravity="center"
            android:text="1"
            android:textColor="#000000"
            android:textSize="14sp" />

        <Button
            android:id="@+id/miuns"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_marginLeft="8dp"
            android:onClick="decrement"
            android:text="-" />
    </LinearLayout>

    <TextView
        android:id="@+id/price"
        android:layout_width="100sp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="8dp"
        android:gravity="center"
        android:text="order summary"
        android:textAllCaps="true"
        android:textSize="16sp"
        app:layout_constraintLeft_toRightOf="@id/cup"
        app:layout_constraintTop_toBottomOf="@id/linearLayout" />

    <TextView
        android:id="@+id/order_summary_text_view"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="8dp"
        android:gravity="center"
        android:text="0$"
        android:textSize="16dp"
        app:layout_constraintLeft_toRightOf="@id/cup"
        app:layout_constraintTop_toBottomOf="@id/price" />

    <Button
        android:layout_width="100sp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16sp"
        android:layout_marginTop="8sp"
        android:gravity="center"
        android:onClick="submitOrder"
        android:text="order"
        android:textSize="16sp"
        app:layout_constraintLeft_toRightOf="@id/cup"
        app:layout_constraintTop_toBottomOf="@id/order_summary_text_view" />
</android.support.constraint.ConstraintLayout>

Main Activity file:

package com.example.justjava;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

/**
 * This app displays an order form to order coffee.
 */
public class MainActivity extends AppCompatActivity {

    int quantity = 1;
    double pricePerCup = 2.90;
    String name = "Pawel";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
    public void increment(View view) {
        quantity = quantity +1;
        displayQuantity(quantity);
    }
    public void decrement(View view) {
        quantity = quantity - 1;
        displayQuantity(quantity);
    }
    private String createOrderSummary(double price){
        String orderSummary = "Name: " + name + "nQuantity: " + quantity + 
    "nTotal price: $" + price + "nThanks!";
        return orderSummary;
    }

    private double calculatePrice(int count, double price){
        return count*price;
    }

    /**
     * This method displays the given text on the screen.
     */
    private void displayMessage(String message) {
        TextView orderSummaryTextView = 
    findViewById(R.id.order_summary_text_view);
        orderSummaryTextView.setText(message);
    }
    /**
     * This method is called when the order button is clicked.
     */
    public void submitOrder(View view) {
        double totalPrice = calculatePrice(quantity, pricePerCup);
        String priceMessage = createOrderSummary(totalPrice);
        displayMessage(priceMessage);
    }

    /**
     * This method displays the given quantity value on the screen.
     */
    private void displayQuantity(int number) {
        TextView quantityTextView = findViewById(R.id.quantity_text_view);
        quantityTextView.setText("" + number);
    }

}

#java #android #xml #android-studio

Вопрос:

В моем файле AndroidManifest отображается ошибка «Неразрешенный класс «MainActivity»», но у меня есть класс java и файл с таким именем в пакете , и он должен быть первым действием программы, поэтому, когда я пытаюсь запустить программу, она выходит из строя, я проверил свой код, но не смог найти там никаких проблем .

java-код для файла MainActivity

 package com.example.tictactoe;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.Button;
import android.content.Intent;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    Button forward;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        forward = (Button)findViewById(R.id.start);
        forward.setOnClickListener(new View.OnClickListener()
                                    {
                                       @Override
                                       public void onClick(View v)
                                       {
                                           startActivity(new Intent(MainActivity.this,GameUi.class));
                                       }
                                    });
    }
    @Override
    public void onBackPressed() {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setCancelable(false);
        builder.setMessage("Do you want to Exit?");
        builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        builder.setNegativeButton("No",new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        AlertDialog alert=builder.create();
        alert.show();
    }
}
 

java-код для второго действия, которое использует моя программа («GameUi.java»)

 package com.example.tictactoe

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.os.Bundle;

public class GameUi extends AppCompatActivity {
    Button btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_game_ui);
        btn=(Button)findViewById(R.id.backbtn);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    startActivity(new Intent(GameUi.this, MainActivity.class));
            }
        });
    }
}
 

AndroidManifest file code

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

    <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/Theme.TicTacToe">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

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

Код xml-файла основной активности

 <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#E5E6AD"
        tools:context=".MainActivity">
    <TextView
        android:id="@ id/Heading"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_row="0"
        android:layout_column="0"
        android:layout_marginBottom="332dp"
        android:editable="false"
        android:text="Hello Aliens!"
        android:textAlignment="center"
        android:textColor="#000000"
        android:textSize="50dp"
        android:textStyle="bold|italic"
        app:layout_constraintBottom_toBottomOf="parent"
        tools:layout_editor_absoluteX="16dp" />

    <ImageView
        android:id="@ id/Alienimg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="36dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@id/Heading"
        app:srcCompat="@drawable/ic_launcher_foreground" />
    
    <Button
        android:id="@ id/Startbtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#000066"
        android:letterSpacing="0.5"
        android:padding="0dp"
        android:text="Start"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.498"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@ id/Alienimg"
        app:layout_constraintVertical_bias="0.886" />

</androidx.constraintlayout.widget.ConstraintLayout>
 

введите описание изображения здесь

Комментарии:

1. Вставьте свою ошибку logcat при сбое приложения.

2. пожалуйста, вставьте activity_main.xml

3. Файл (Верхнее меню) -> Аннулировать кэш / перезапустить. Это должно решить вашу проблему

Ответ №1:

В твоем классе я не вижу пакета сверху. Попробуйте добавить его и посмотрите, если вы все еще сталкиваетесь с проблемой, попробуйте аннулировать и перезапустить.

 package com.example.tictactoe;
 

Комментарии:

1. На самом деле я добавил файлы в пакет , который я пропустил, чтобы показать это на stackoverflow, Извините, что я исправил это сейчас.

Ответ №2:

Это является причиной ошибки

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

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

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

фильтр намерений используется для определения того, какое действие будет вашим первым действием ( при запуске приложения для Android ). Вы можете использовать его в обоих действиях, чтобы приложение перепутало, какое из них является вашим первым действием, поэтому они выдают ошибку.

В случае, если основная активность-это ваше первое действие

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

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

 

Комментарии:

1. Я так не думаю. это проблема, верно. но это просто делает два приложения, которые открываются в разных видах деятельности.

2. Это не причина сбоя, я проверил это в своем приложении, работает.

3. спасибо, что указали на то, что на самом деле я тестировал свое второе действие, так что я поставил фильтр намерений, но мое приложение все еще выходит из строя, я попытался создать новый пакет, но все равно не сработало, я не думаю, что это было необходимо, но проверить, но после этого тоже не сработало

4. @Паста Ачинтяшарма activity_main.xml

Ответ №3:

Ваш манифест в порядке ( я думаю, вы исправили проблему с фильтром намерений на основе ответа Абдуллы Шейха). проблема заключается в том, что эта строка в MainActivity :

     forward = (Button)findViewById(R.id.start);
 

потому что ваш идентификатор кнопки Startbtn не start

просто замените это на :

 forward = (Button)findViewById(R.id.Startbtn);
 

также в activity_main и ImageView удалите

app:srcCompat="@drawable/ic_launcher_foreground"

или найдите другой src для рисования.

This is the most common issue faced by so many developers when creating a new Android Studio Project. This issue occurs because Android Studio was not able to detect the default MainActivity in your Android Studio Project. In this article, we will take a look at four different ways with which we can fix this error in your Android Project. 

Pre Requisites: You should be having your Android Studio project build which is showing this type of error as Default Activity not found.

Method 1: Cleaning your project

In this method, we will be cleaning our whole project and sync all the Gradle files because Android Studio sometimes doesn’t detect the Activity. So we will be cleaning the tour project in this method. For cleaning our Android Studio project. Navigate to the Build option in the top bar and then click on it and after that, you will get to see an option to Clean your Project. Click on that option to clean your project. The option is shown below screenshot. 

Method 2: Cleaning and Rebuilding your Project

In this method, we will be cleaning as well as rebuilding our project. After cleaning our project sometimes our files in the Android Studio project are rearranged. So to arrange these files in a proper manner we have to rebuild our project. In this project first of all we have to clean our project as shown in Method 1 and then after Rebuild your project. For Rebuilding your project click on the Build option in the top bar and then click on the Rebuild Project option to rebuild your project. The screenshot is shown below for these options. 

Method 3: Restarting your project using Invalidate Caches and Restart option

In this method, we will be restarting our project using Invalidate Caches and Restart option. For using this option navigate to the File option and then click on Invalidate Caches and Restart option you will get to see this option in the below screenshot. 

After clicking on this option you will get to see the below screenshot. In this click on Invalidate Caches and Restart option to Restart your Android Studio project. 

Method 4: Check the Manifest file for your launcher Activity

In this method, we will verify if our Activity name is declared in our Manifest file or not. For checking this we simply have to Navigate to the Manifest file and check your Manifest file if your Activity name is mentioned in that file or not. The code for a sample Manifest file is given below. Comments are added in the code to get to know in detail. 

XML

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

    package="com.example.gfgpagination">

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

    <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/Theme.GFGPagination">

        <activity android:name=".MainActivity">

            <intent-filter>

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

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

            </intent-filter>

        </activity>

    </application>

</manifest>

 After updating the code for your AndroidManifest.xml file. Now run your app and it will work properly. 

Last Updated :
09 Mar, 2021

Like Article

Save Article

Luc1fer99

Откройте AndroidManifest.xml и добавьте следующее

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

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

SwoDs

Вам ошибки перевести?

Все же написано:

Ошибка запуска «app»: Activity по умолчанию не найдено
Ошибка запуска «app»: «MainActivity» не объявлено в AndroidManifest.XML


Комментировать

Понравилась статья? Поделить с друзьями:

Не пропустите эти материалы по теме:

  • Яндекс еда ошибка привязки карты
  • Android auto яндекс музыка ошибка подключения
  • Android auto ошибка 8 4pda
  • Android auto ошибка 16 при подключении xiaomi
  • Android auto yandex music ошибка подключения

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии