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:22

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

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

I changed my Intent-filter to

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

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.

查看更多
回忆,回不去的记忆
4楼-- · 2018-12-31 18:25

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

    <activity
        android:name="FULL_NAME_OF_YOUR_ACTIVITY"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

This should be inserted between:

<application> </application>

No need in invalidating caches.

查看更多
妖精总统
5楼-- · 2018-12-31 18:26

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:

<activity
        android:name="com.your.package.name.YourActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

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.

查看更多
若你有天会懂
6楼-- · 2018-12-31 18:28

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

查看更多
流年柔荑漫光年
7楼-- · 2018-12-31 18:28

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.

查看更多
登录 后发表回答