且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

“未找到默认活动"关于 Android Studio 升级

更新时间:2023-01-19 14:27:56

我无法评论为什么升级IntelliJ可能会导致这个问题,因为我不使用它.

但是,该错误:未找到默认活动"似乎在告诉您,您没有在 AndroidManifest.xml 中声明的活动被标记为主要活动,在应用程序启动时启动.

您应该至少有一个类似这样的活动:

MainActivity.javaactivity_main.xml

I upgraded IntelliJ Idea from 12.0.4 to 12.10.

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

Error: Default Activity Not Found

I reverted back to 12.0.4 and it everything works again.

Any ideas? I think it might be an issue with a missing plugin. Since the plugin is not installed, it is not able to find the default activity. Another thing could have been a local config, but I doubt it. I deleted the configuration folder to verify and that didn't change anything.

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.

Edit:

Additional details (AndroidStudio4.1.2) if the project is created as EmptyApplication then the developer must manually create below 3 files to avoid Default Activity Not Found error

AndroidManifest.xml MainActivity.java activity_main.xml