ADT 不允许创建 Android Activity

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22190578/
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-08-20 05:37:38  来源:igfitidea点击:

ADT will not allow creation of Android Activity

androideclipseadt

提问by NewShelbyWoo

I installed the ADT bundle from http://developer.android.com/sdk/index.htmlyesterday, and I was following a basic Hello World tutorial. I created a new Android Application Project with a Blank Activity named MainActivity. The resulting project has an empty srcfolder and empty res\layoutfolder. There is a R.javafile in the genfolder but it has no reference to MainActivity. This is what the SDK manager says I have installed

我昨天从http://developer.android.com/sdk/index.html安装了 ADT 包,我正在学习基本的 Hello World 教程。我创建了一个新的 Android 应用程序项目,其中包含一个名为MainActivity. 生成的项目有一个空src文件夹和一个空文件res\layout夹。R.java文件gen夹中有一个文件,但它没有引用MainActivity. 这就是 SDK 管理器所说的我已经安装

  • Android SDK Tools v 22.6
  • Android SDK Platform-tools v 19.0.1
  • Android SDK Build-tools v 19
  • SDK Platform v 3
  • ARM EABI v7a System Image v 2
  • Android Support Library v 19.0.1
  • Google USB Driver v 9
  • Android SDK 工具 v 22.6
  • Android SDK 平台工具 v 19.0.1
  • Android SDK 构建工具 v 19
  • SDK 平台 v 3
  • ARM EABI v7a 系统映像 v 2
  • Android 支持库 v 19.0.1
  • 谷歌 USB 驱动程序 v 9

I also tried manually creating an activity by right clicking the srcfolder and going to Android Activity, but when I hit Finish on the creation wizard, nothing happens. Does anyone have any clues as to what's going on? Did I miss a key component to install or something?

我还尝试通过右键单击src文件夹并转到 Android 活动来手动创建活动,但是当我在创建向导上点击完成时,没有任何反应。有没有人知道发生了什么?我是否错过了要安装的关键组件或其他什么?

采纳答案by Akshay

If you updated to Android SDK Tools version 22.6, you are required to Update DDMS Tools and Plugins.

如果您更新到 Android SDK 工具版本 22.6,则需要更新 DDMS 工具和插件。

Go to "Help Menu Bar" -> "Install New software" and install (this will update it) url: https://dl-ssl.google.com/android/eclipse/

转到“帮助菜单栏”->“安装新软件”并安装(这将更新它)网址:https: //dl-ssl.google.com/android/eclipse/

Also update "Developer Tools"and "NDK Plugins"to latest Version. This steps is useful for me and worked also.

还将“开发人员工具”“NDK 插件”更新到最新版本。这些步骤对我有用并且也有效。

回答by patrickfdsouza

The comment see commentby NewShelbyWoosolved the issue

注释见注释通过NewShelbyWoo解决问题

回答by MohanRaj S

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:

有四种方式:

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

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

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

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

Downgrade to 22.3.0 for example

例如降级到 22.3.0

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

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

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.,

和搜索。,

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

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

i followed those steps to solve the above problem. Hope this is work's,Thank you :)

我按照这些步骤来解决上述问题。希望这是工作的,谢谢:)

回答by raju

When you upgrade to SDK tools by 22.x you need to upgrade ADT plugin. follow these steps to upgrade ADT:

当您通过 22.x 升级到 SDK 工具时,您需要升级 ADT 插件。请按照以下步骤升级 ADT:

Help > Install New software install

帮助 > 安装 新软件安装

add the below url and click on next.

添加以下网址,然后单击下一步。

url: https://dl-ssl.google.com/android/eclipse/.

网址:https: //dl-ssl.google.com/android/eclipse/

But some times it complaining about conflicts, in that case,

但有时它会抱怨冲突,在那种情况下,

First uninstall the existing ADT plug in. and try again.

首先卸载现有的 ADT 插件,然后重试。

To Uninstall Existing ADT plug in:

卸载现有的 ADT 插件:

Help>About Eclipse Platform> and delete the pluging.

Help>About Eclipse Platform> 并删除插件。

now follow the above steps.

现在按照上述步骤操作。

回答by dbconfession

workspace has to be set to the the SDK folder. After doing this, I have had no problems. For example, after downloading and installing Eclipse, my directory structure is as follows:

工作区必须设置为 SDK 文件夹。这样做之后,我没有任何问题。比如下载安装Eclipse后,我的目录结构如下:

/Users/username/Development/adt-bundle-mac-x86_64-20140702/
    /eclipse/
    /sdk/
        /HelloWorld/

It's annoying because the default workspace was set as documents/workspace(changing permissions with chmod 777 workspace didn't work in my case. Plus it's inconvenient that all my projects are mixed in with other folders in the SDK folder.

这很烦人,因为默认工作区设置为documents/workspace(使用 chmod 777 工作区更改权限在我的情况下不起作用。另外,我的所有项目都与 SDK 文件夹中的其他文件夹混合在一起很不方便。

回答by Droid Teahouse

With Luna and ADT plug-in version: 23.0.4.1468518 there is a patch available right now to fix:

Luna 和 ADT 插件版本:23.0.4.1468518 现在有一个补丁可以修复:

https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=82393

https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=82393

Just follow directions near bottom to uninstall and download and install the issue as archive|local

只需按照底部附近的说明卸载并下载并将问题安装为存档|本地