Error: Default Activity Not Found

匿名 (未验证) 提交于 2019-12-03 09:02:45

问题:

I upgraded IntelliJ Idea 12.0.4 to 12.10.

Now all the modules in my Android project give the error:

Error: Default Activity Not Found

I reverted to 12.0.4 and it works.

Any ideas ?? I think it might be related to some plugins not being installed cause the only other thing could have been a local config but I deleted the configuration folder to confirm and that didn't change anything.

回答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... 


回答2:

I can't comment on why the upgrade of IntelliJ might cause this problem because I don't use it.

However, that error: "Default Activity Not Found" seems to be telling you that you don't have an activity declared in 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:

If you don't have at least one activity with an intent filter like that, you would most likely see the error message you have included here.

You should add that intent filter to the Activity that you wish to open when you start the application, and that should fix your problem.



回答3:

You app have launch activity default?

possibly this could be your mistake

Step 1: Select Edit Configurations

Step 2: watch this warning: Default Activity not found

Step 3: select a default activity

Step 3: Save your changes and finish

Good Luck



回答4:

The correct way to do this is to add the following to the Manifest file:

    

This should be inserted between:

No need in invalidating caches.



回答5:

Try to right click on the project and choose Open Module Settings. Then go to the Sources tab in your module, find the src folder, right click on it and mark it as Sources (blue color).

EDIT: There is no sources tab in later versions of Android Studio, but you can edit the build.gradle file instead: https://stackoverflow.com/a/22028681/1101730



回答6:

Nothing above helped me. After some time I found that IDEA changed action names to uppercase. Like:

After reverting to normal, IDEA recognizes default activity:



回答7:

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



回答8:

If you are working on a widget app this solution should work for you:

  1. Go to Edit Configuration
  2. Set Launch Option to nothing


回答9:

@TouchBoarder almost had it. Although selecting "Do not launch Activity" results in nothing launching.

In Android Studio under Run/Debug Configuration -> Android Application -> General -> Activity -> select the option "Launch:"

Choose your Activity. This doesn't exactly fix the intended behaviour but rather overrides it correctly.



回答10:

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



回答11:

I found this in my code:

If you look very carefully, it should be instead.

Apparently, I refactored an "activity" somewhere, and it changed names in the AndroidManifest as well.



回答12:

I changed my Intent-filter to

Just add DEFAULT option as well. I was using Process Phoenix library and it prompted me to define a default intent. This addition solved my problem.



回答13:

in my case i refactored a member variable that was named "activity", i renamed it to "context" ... i found out that the refactor was made to the activity tags in manifest, and i found them context tags instead ... this is really stupid from Android Studio !!



回答14:

  1. Build -> Rebuild Project
  2. File -> Invalidate Caches.. -> Invalidate and restart

It works for me. Rebuild project to make sure that no errors in project. Then we can invalidate cache.



回答15:

just faced this error on android studio 2.1.2. solved by adding MAIN/LAUNCHER intent-filter to default activity in flavour manifest, though filter already was in default activity in default manifest. It even was in merged manifest, but studio can't found it until i duplicated filter in both manifests.



回答16:

my experience: make sure that all your java file has been indentify,if IDEA not indentify your java file ,so he not able to understand what's "Activity" means

good luck :)



回答17:

Well I got this error too,

Error: Default Activity Not Found

well in my case it was for wear module ..I don't need an Activity there so what i do is simply

  1. go to edit configuaration ->wear-> Launch Options->Launch->Nothing.
  2. Apply changes.Click Ok.
  3. Remove the existing code for default activity from your manifest file.

Note: Don't forget to Clean Project and Sync Gradle Files.



回答18:

I got this error.

And found that in menifest file in launcher activity i did not put action and category in intent filter.

Wrong One:

 

Right One:



回答19:

I started with a demo app and modified it. I change the java path inside source from com -> example -> foo to my own and edited the manifest; however, Android Studio (0.8.7) got very confused.

I tried everything listed above and none of it worked for me. Maybe it even made things worse?

My final solution was to edit .iml in the .idea subdirectory by opening it up in Android Studio (aka text editor).

Before:

I (re)added the src directory (2nd line). After:

After saving it, Android Studio reloaded and started functioning as expected.



回答20:

After updating Android Studio from 1.2.x to 1.3 I got the same problem and I tried all suggestions but nothing worked. Then I did this:

Go to Run/Debug Configurations. Select the configuration that gives the error and delete it. Create a new one with the same name and settings. After that, reconnect the USB cable and run the application.

This solved the problem for me.



回答21:

Error: Default Activity Not Found

I solved this way
Run>>Edit Configuration >>Android Application >> Enter the path of your default activity class in "Launch" Edit Box.



回答22:

Invalidate Caches / Restart



After that, your app must be run!



回答23:

Android Manifest.xml set the starting activity like following



回答24:

I was facing similar issue recently. The issue was with activitymanifest xml file. please check if taglines are closed properly.



回答25:

I've encountered the same issue. For some reasons, android Studio replaced all the android:name attributes in most of XML files, including the manifest, to android:subject which isn't recognized by Android Studio.

As you can see in the picture above the IDE doesn't recognize the android:subject attribute. As a result, it won't be able to read the lines which specify the MainActivty.

The solution is simply to change every android:subject to android:name and then Rebuild the project from Build menu -> Rebuild Project. You might encounter the same issue when rebuilding the project, so do the same as above.



回答26:

Well, I don't understand Android Studio sometimes...

I encountered the same problem and tried the what the answers here told, but to no avail. And then I changed one thing: the action in my intent-filter was having the action name all in caps and I changed it to small and left only the word MAIN in caps, and it solved the problem! How absurd! I hope this can help someone.



回答27:

This will help someone who landed on this page like me

I got the error Error: Default Activity Not Found after I copy pasted a code from an online course.

The mistake was in the first line MainActivity.java file

Instead of package com.example.myname.justjava;

the first line was package com.example.android.justjava;

from the code provided for learning

Rectifying it got rid of the error



回答28:

ugly but worked for me:

Had this error message, my problem was in a module, I just deleted the application tag compleatly from my module's manifest and it worked.

(delete ic_launcher from the module library as well)

was:

now:



回答29:

You Might be missing attributes. Make sure to include this activity inside manifest file



回答30:

check all the line in your manifest.

in my case i have this error :

android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen" 

nothing in the logcat



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!