Error: Default Activity Not Found

2018-12-31 17:39发布

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.

30条回答
柔情千种
2楼-- · 2018-12-31 18:07

I found this in my code:

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

If you look very carefully, it should be <activity android:name=".MainActivity"> instead.

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

查看更多
路过你的时光
3楼-- · 2018-12-31 18:08

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.

查看更多
裙下三千臣
4楼-- · 2018-12-31 18:09

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.

查看更多
荒废的爱情
5楼-- · 2018-12-31 18:11

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楼-- · 2018-12-31 18:11

I got this error.

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

Wrong One:

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

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

</activity>

Right One:

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

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

</activity>
查看更多
美炸的是我
7楼-- · 2018-12-31 18:12

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 <projectname>.iml in the .idea subdirectory by opening it up in Android Studio (aka text editor).

Before:

<content url="file://$MODULE_DIR$">
  <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
</content>

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

<content url="file://$MODULE_DIR$">
  <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
</content>

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

查看更多
登录 后发表回答