eclipse 新建Android应用项目无法创建空白Activity

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22755432/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 21:37:48  来源:igfitidea点击:

New Android Application Project Can't Create Blank Activity

androideclipse

提问by Nikolius Lau

I am still new in android development and just decided to learn. however i encounter some problem that drive me nuts this couple hours.. i just want to create a new project with this setting

我还是 android 开发的新手,只是决定学习。但是我遇到了一些问题,这几个小时让我发疯..我只想用这个设置创建一个新项目

New Project Setting

新项目设置

the problem is i can't create new blank activity with it, it says it requires a build target API version of at least 14, and the current version is 8

问题是我无法用它创建新的空白活动,它说它需要至少 14 的构建目标 API 版本,而当前版本是 8

Activity Warning

活动警告

I just want to try build an app that support from Android 2.2 (API 8) onwards.. is that just not possible right now to create an Android 2.2 compatible apps with blank activity template? so in order to use blank activity template i must use Android 4.0 (API 14)? is that correct?

我只是想尝试构建一个支持 Android 2.2 (API 8) 以后的应用程序..现在无法使用空白活动模板创建与 Android 2.2 兼容的应用程序吗?所以为了使用空白活动模板,我必须使用 Android 4.0 (API 14)?那是对的吗?

回答by user3439968

It's new feature of ADT 22.6.2

这是 ADT 22.6.2 的新特性

Even in "None" theme ADT(22.6.2) create "Fragment Layout"

即使在“无”主题 ADT(22.6.2) 中创建“片段布局”

There is four ways:

有四种方式:

  1. Try to change "Target" and "Compile" to API 14 or higher. But you need then remove all entries of "Fragment Layouts"

  2. Uncheck "Create activity" checkbox, and create activity manually. Good howto: Best way to add Activity to an Android project in Eclipse?

  3. Downgrade to 22.3.0 for example

  4. Try to change templates. In link below you find howto.

  1. 尝试将“目标”和“编译”更改为 API 14 或更高版本。但是您需要删除“片段布局”的所有条目

  2. 取消选中“创建活动”复选框,然后手动创建活动。好方法在 Eclipse 中将 Activity 添加到 Android 项目的最佳方法?

  3. 例如降级到 22.3.0

  4. 尝试更改模板。在下面的链接中,您可以找到操作方法。

I use third way for my apps with APIs lower 14. In different directories I have installed 22.3.0 and 22.6.2

我对 API 低于 14 的应用程序使用第三种方式。在不同的目录中,我安装了 22.3.0 和 22.6.2

There in 22.6.2 is some other bugs with blank files and problems with AVD. New version of ADT really buggy...

22.6.2 中还有一些其他错误,包括空白文件和 AVD 问题。新版本的 ADT 真的有问题...

Look also this links:

也看看这个链接:

ADT blank activity created with fragment activity..

使用片段活动创建的 ADT 空白活动..

Eclipse doesn't generate MainActivity.java & activity_main.xml

Eclipse 不生成 MainActivity.java & activity_main.xml

and search, yep )

和搜索,是的)

https://stackoverflow.com/search?q=adt+22.6

https://stackoverflow.com/search?q=adt+22.6



Added some new ways.

添加了一些新方法。

How I use it now:

我现在如何使用它:

  1. You can create project in 22.3.0 or lower. Then open it in 22.6 or greater.
  2. You can create project in 22.3.0 or lower and leave it blank. Then in 22.6 or greater you can use this blank project as template. Just copy this template-project and past it with new name as you new-project in Eclipse workspase.
  1. 您可以在 22.3.0 或更低版本中创建项目。然后在 22.6 或更高版本中打开它。
  2. 您可以在 22.3.0 或更低版本中创建项目并将其留空。然后在 22.6 或更高版本中,您可以将此空白项目用作模板。只需复制此模板项目,并在 Eclipse 工作区中新建项目时使用新名称将其粘贴。

Enjoy! )

享受!)

回答by user3459475

it is going to be tricky building for such a version, you may leave you minimum Sdk at yoru desired. Still you must increase max, also if your minimum is anything less than 15, the ADK is now building an extra folder(new stuff) In truth the new version of the ADt is annoying, I am just starting and now you will see they have enforced the use of fragments.

对于这样的版本来说,构建起来会很棘手,你可能会在你想要的时候留下最少的 Sdk。你仍然必须增加最大值,如果你的最小值小于 15,ADK 现在正在构建一个额外的文件夹(新东西)事实上,新版本的 ADt 很烦人,我刚刚开始,现在你会看到他们有强制使用片段。

回答by Harison Silva

I figured out that we can use Empty Activity instead of Blank Activity. Now in Empty is created a fragment, layout and R.java is updated.

我发现我们可以使用 Empty Activity 而不是 Blank Activity。现在在 Empty 中创建了一个片段,布局和 R.java 被更新。

回答by user1807268

I was in the same boat so I tried....And it worked!

我在同一条船上,所以我尝试了......它奏效了!

This is with a brand new empty project i tried to start with SDK 8 set for min and target.

这是一个全新的空项目,我尝试从为 min 和 target 设置的 SDK 8 开始。

I was able to change the min and target SDK to a higher version(in my case 21). That allowed me to add an "Empty Activity". After the activity was added I just change the min and target back to 8. There were not any compile complaints and I was able to run it in a 2.2 emulator after I did the change

我能够将最小和目标 SDK 更改为更高版本(在我的情况下为 21)。这让我可以添加一个“空活动”。添加活动后,我只是将最小和目标更改回 8。没有任何编译投诉,并且在我进行更改后,我能够在 2.2 模拟器中运行它

回答by Ojonugwa Jude Ochalifu

Change the minimum required SDK to 9 and the target SDK to 18

将最低要求的SDK改为9,目标SDK改为18

回答by abili

create the project independently and u have to uncheck the create activity thing, then go back to to create android activity on its own then choose the master/detail view press next and check the launch activity box then press back and choose blank or empty activity then press finish all will be done, that's what I used and it worked out

独立创建项目,你必须取消选中创建活动的东西,然后返回到自己创建android活动然后选择主/详细视图按下一步并选中启动活动框然后按回并选择空白或空活动然后按完成所有将完成,这就是我使用的并且解决了