Меню

Default activity not found android studio ошибка

I just experienced the same error in Android Studio 1.5.1. and just found the source of the problem. I am not sure whether the cause was a human error or some strange glitch in the behaviour of the IDE, but none of the existing StackOverflow questions about this subject seemed to show anything about this so I figured I post it as an answer anyway.

For me, either one of my team members or the IDE itself, had changed the launcher activities manifest entry, causing it to look like this:

        <activity
            android:name="com.rhaebus.ui.activities.ActivitySplash"
            android:launchMode="singleInstance"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <id android:name="android.intent.id.LAUNCHER" />
            </intent-filter>
        </activity>

While it should, in fact, look like this:

        <activity android:name="com.rhaebus.ui.activities.ActivitySplash"
            android:launchMode="singleInstance"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" /> <!-- Change Here -->
            </intent-filter>
        </activity>

So please double, triple, quadruple check the format of your launcher activity in the manifest and you might be able to save yourself some time.

Hope this helps.

EDIT:
I strongly suggest people not to go with the answers that suggest to manually select a launcher activity inside the configuration options of your module, as this caused the application to no longer be shown in the list of installed apps on both the Samsung Galaxy S5 Neo and the Samsung Galaxy S6 (at least for me).

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. 

When running an app in the android studio, this type of error, ‘Default Activity not found’. This means the app does not detect the default activity. Also checked the manifest file for the intent filter, but didn’t find any problem. Default activity is proper but at that time error occurs while launching the app in the emulator. Also checked the default activity but didn’t find any solution.

Default Activity not found

So today, we solve the ‘Default Activity Not Found’ issue in Android Studio. We will try every possible way. We are going to solve each method step by step.
Let’s try to solve the problem ‘Could not identify launch activity: Default activity not found’ while launching an app in an emulator or an Android device.

What exactly is the logcat error in Android Studio?

At that time on clicking run, app does not installed and get error like this below logcat error.

Could not identify launch activity: Default Activity not found
Error while Launching activity

To resolve this error, first check the ‘androidmanifest file’
Manifests⇾androidmanifest.xml and check if the default activity is set. Check some times launching activity is not added, if all is correct state then this problem does not occur in the manifest file.

How to solve ‘Could not identify launch activity: default activity not found’ in Android Studio?

Here’s a different way. This method will be useful in solving your problem.

Method 1:clean project
First,
try to clean the project.
Build⇾clean project.
After clean project, run again.

Method 2: Rebuild Project
If method 1: Not working, then try another method.
In this method, the Rebuild project.
Build⇾Rebuild Project.
After completing the rebuild process, run your app.

Method 3: Reload all from disk
If the second attempt also fails and the same problem occurs then try this step.
file⇾Reload All from disk.
After that, sync the project with gradle files.
After finishing Gradle build, run your app in any android device or emulater.

Method 4:invalidate caches/restar…
If the third method doesn’t work and the same problem occurs, don’t worry all the possible solutions are given here.
file⇾invalidate caches/Restart…⇾ just Restart.
After this, your Android Studio just restart.
then run your app.

Method 5:invalidate and restart
If the above method does not work, then this method may work.
file⇾invalidate caches/Restart…⇾invalidate and restart.
In this method, all invalidate caches will be cleared of all invalidate data.
Later Restart Android Studio and run the app.

Method 6:specified activity
The same
problem occurs after trying all the above methods again and again found default activity was not found. So now we Will try to add the specified launching activity in the android studio.
app⇾edit configuration…⇾launch options⇾specified activty⇾select specific activty class.
afterward. Select the specified activity and run your app.


Error Description:

After upgrading to IntelliJ Idea 12.0.4 to 12.10.
All the modules in the Android project give the error:

Error: Default Activity Not Found

Solution 1:

  • If we see that error occur after upgrading versions of IntelliJ IDEA or Android Studio, or after Generating a new APK, we may need to refresh the IDE’s cache.
File -> Invalidate Caches / Restart...
click below button to copy the code. By — android tutorial — team

Solution 2:

  • Right click on the project and choose Open Module Settings. Then go to the Sources tab in the module, find the src folder, right click on it and mark it as Sources (blue color).
  • There is no sources tab in later versions of Android Studio, but we can edit the build.gradlefile instead.

Solution 3:

  • In Android Studio under Run/Debug Configuration -> Android Application -> General -> Activity -> select the option «Do not launch Activity».

Solution 4:

  • If you are working on a widget app:
    • Go to Edit Configuration
    • Set Launch Option to nothing

Solution 5:

  • In case the application doesn’t have an Activity (only a service for example), change the run/debug configuration ‘Launch’ option to ‘Nothing’.

Assuming your AndroidManifest.xml is setup properly.

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
    <application ...>
        <activity
            android:name=".MainActivity"
            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>
    </application>
</manifest>

You can try changing Android Studio -> Run -> Edit Configurations, at Android App -> app -> General -> Launch Options, changed from Default Activity to Specific Activity then pick and activity. If the problem still persist, then this is a Android Studio problem and not a configuration issue.

NOTE: You can also try opening other Android projects.

Solutions

You might need to try one or more of the following solutions.

  1. Android Studio -> File -> Invalidate Caches / Restart ...
  2. Android Studio -> Build -> Clean Project / Rebuild Project
  3. Android Studio -> File -> Sync Project with Gradle files
  4. Close Android Studio, goto C:Users[USER].AndroidStudio3.3system and delete caches directory.

NOTE: Solution 4 work for my case.

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy — discover travel places in Malaysia, Singapore, Taiwan, Japan.

⚠️ 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.

Every Android Application must one application tag in the Manifest file and within it, there must be an Activity with <intent-filter> tag with action and category sub-tags. Whichever activity has these tags within it is the Launcher/Default activity which gets loaded when the App is run on a device.

Note you can have more than once activity with <intent-filter> tags in it, in such a scenario you would find App launcher icons when the App is installed on the device.

File : AndroidManifest.xml

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        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>

</manifest>

Note that the Activity tag should be inside the <application> </application> tag.

Android Studio Error - Default Activity not found

Android Studio Error — Default Activity not found

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

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

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Deerma dem f600 ошибка e1
  • Deep sea electronics ошибки на дисплее