Java Eclipse 不创建主活动和布局

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

Eclipse doesn't create Main Activity and layout

javaandroideclipse

提问by Cookie Monster

I can't start new projects anymore. This is what I do...

我不能再开始新的项目了。这就是我所做的...

  • Start Eclipse.
  • New Android Application
    • min API 8
    • target API 18
    • compile API 19
    • create activity : checked
    • activity name : MainActivity
    • layout name : activity_main
    • finish
  • 启动日食。
  • 新的安卓应用
    • 最小API 8
    • 目标API 18
    • 编译API 19
    • 创建活动:选中
    • 活动名称: MainActivity
    • 布局名称: activity_main
    • 结束

When I open the project (it doesn't even open MainActivity.javaas it should be) : - srcfolder is empty - res/layoutfolder is empty

当我打开项目时(它甚至没有MainActivity.java按原样打开): - src文件夹为空 - res/layout文件夹为空

But AndroidManifest.xmlexists. It was working perfectly before and I was able to create projects then it just suddenly broke.

但是AndroidManifest.xml存在。它之前运行良好,我能够创建项目,然后它突然崩溃了。

I'm using APIs 18 and 19 all installed and up to date.

我使用的 API 18 和 19 都已安装并且是最新的。

采纳答案by Werner

I had the same problem yesterday after updating the latest packages on the Android SDK Manager.

我昨天在 Android SDK Manager 上更新了最新的软件包后遇到了同样的问题。

Fixed it by updating the Eclipse plugin: Run Eclipse> Help> Install new software> Paste the URLhttps://dl-ssl.google.com/android/eclipse/then press Enter. After updating the plugin, I created a test project with the main activity and menu was created by default as normal.

通过更新 Eclipse 插件修复它:Run Eclipse> Help> Install new software> Paste the URLhttps://dl-ssl.google.com/android/eclipse/然后按Enter。更新插件后,我创建了一个带有主活动的测试项目,默认情况下会正常创建菜单。

回答by Adithya

I had a problem with opening the layout folder. I needed a xml file with the contents as below:

我在打开布局文件夹时遇到问题。我需要一个 xml 文件,其内容如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
</LinearLayout>

So,this is what I did.I tried updating eclipse but, the problem persisted. So,I just created a new xml file by right-clicking the layout folder.After creating the file,I just copy-pasted the aforementioned content.Hope it helps!

所以,这就是我所做的。我尝试更新 eclipse,但问题仍然存在。所以,我只是通过右键单击布局文件夹创建了一个新的 xml 文件。创建文件后,我只是复制粘贴了上述内容。希望它有所帮助!

回答by Toporokis

It happened to me too. It suddenly stopped creating MainActivity.javaand layout. I could fix it by updating Eclipse:
Help -> Check for updates -> Select all

它也发生在我身上。它突然停止创建MainActivity.java和布局。我可以通过更新 Eclipse 来修复它:
帮助 -> 检查更新 -> 全选

回答by darupa

I had the same problema also. I fixed the problem follow the Werner recomendation. Eclipse --> Help --> Install new software --> Pasted URL http://dl-ssl.google.com/android/eclipse/pressed Enter, but It's important check it out and remove before any copy of the plugin installed in available Software Sites.

我也有同样的问题。我按照维尔纳的建议解决了这个问题。Eclipse --> 帮助 --> 安装新软件 --> 粘贴 URL http://dl-ssl.google.com/android/eclipse/按 Enter,但重要的是在安装插件的任何副本之前检查并删除它在可用的软件站点中。

回答by Dudi72

I had the same problem also. I fixed the problem follow the Werner recomendation. Eclipse --> Help --> Install new software --> Pasted URL http://dl-ssl.google.com/android/eclipse/It fixed my problem.

我也有同样的问题。我按照维尔纳的建议解决了这个问题。Eclipse --> 帮助 --> 安装新软件 --> 粘贴 URL http://dl-ssl.google.com/android/eclipse/它解决了我的问题。

回答by user3327784

I've just had the same issue on Mac 10.9.1. For what appears to be no reason, when creating a new android project, the "src" directory is empty, and there's no activity_main.xml. I tried Werner's fix, but the URL had issues trying to download the files. Deleted Eclipse, and re-installed. This appears to have fixed the issue.

我刚刚在 Mac 10.9.1 上遇到了同样的问题。不知何故,当创建一个新的android项目时,“src”目录是空的,并且没有activity_main.xml。我尝试了 Werner 的修复程序,但该 URL 在尝试下载文件时出现问题。删除Eclipse,然后重新安装。这似乎解决了这个问题。

Actually - still having this issue, even after re-installing Eclipse...

实际上 - 即使在重新安装 Eclipse 之后仍然有这个问题......

回答by neferpitou

I have the same problem before.

我以前也有同样的问题。

Using this Eclipse Update http://dl-ssl.google.com/android/eclipse/did not work for me. I notice this problem when I download the latest updated SDK

使用此 Eclipse 更新http://dl-ssl.google.com/android/eclipse/对我不起作用。我在下载最新更新的 SDK 时注意到这个问题

enter image description here

在此处输入图片说明

Luckily the solution to my problem is very easy. enter image description here

幸运的是,我的问题的解决方案非常简单。 在此处输入图片说明

By Selecting Empty Project instead of Blank Activity makes it working.

通过选择空项目而不是空白活动使其工作。