简体   繁体   English

Eclipse不会创建主要活动和布局

[英]Eclipse doesn't create Main Activity and layout

I can't start new projects anymore. 我不能再开始新项目了。 This is what I do... 这就是我做的......

  • Start Eclipse. 启动Eclipse。
  • New Android Application 新的Android应用程序
    • min API 8 min API 8
    • target API 18 目标API 18
    • compile API 19 编译API 19
    • create activity : checked 创建活动:已检查
    • activity name : MainActivity 活动名称: MainActivity
    • layout name : activity_main 布局名称: activity_main
    • finish

When I open the project (it doesn't even open MainActivity.java as it should be) : - src folder is empty - res/layout folder is empty 当我打开项目时(它甚至没有打开MainActivity.java ): - src文件夹为空 - res / layout文件夹为空

But AndroidManifest.xml exists. AndroidManifest.xml存在。 It was working perfectly before and I was able to create projects then it just suddenly broke. 它之前工作得很好,我能够创建项目然后它突然爆发了。

I'm using APIs 18 and 19 all installed and up to date. 我使用的API 18和19全部安装并且是最新的。

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 URL https://dl-ssl.google.com/android/eclipse/ then press Enter . 通过更新Eclipse插件修复它: Run Eclipse > Help > Install new software > Paste the URL https://dl-ssl.google.com/android/eclipse/,然后按Enter After updating the plugin, I created a test project with the main activity and menu was created by default as normal. 更新插件后,我创建了一个主要活动的测试项目,默认情况下创建的菜单正常。

I have the same problem before. 我之前有同样的问题。

Using this Eclipse Update http://dl-ssl.google.com/android/eclipse/ did not work for me. 使用此Eclipse更新http://dl-ssl.google.com/android/eclipse/对我不起作用。 I notice this problem when I download the latest updated SDK 我下载最新更新的SDK时发现了这个问题

在此输入图像描述

Luckily the solution to my problem is very easy. 幸运的是,解决我的问题很容易。 在此输入图像描述

By Selecting Empty Project instead of Blank Activity makes it working. 通过选择Empty Project而不是Blank Activity使其工作。

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

It happened to me too. 它也发生在我身上。 It suddenly stopped creating MainActivity.java and layout. 它突然停止创建MainActivity.java和布局。 I could fix it by updating Eclipse: 我可以通过更新Eclipse来修复它:
Help -> Check for updates -> Select all 帮助 - >检查更新 - >全选

I had the same problema also. 我也有同样的问题。 I fixed the problem follow the Werner recomendation. 我按照Werner推荐的方式修复了问题。 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键,但重要的是检查它并在安装任何插件副本之前删除在可用的软件站点中。

I had the same problem also. 我也有同样的问题。 I fixed the problem follow the Werner recomendation. 我按照Werner推荐的方式修复了问题。 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/它解决了我的问题。

I've just had the same issue on Mac 10.9.1. 我在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. 对于看似没有理由的,在创建新的android项目时,“src”目录为空,并且没有activity_main.xml。 I tried Werner's fix, but the URL had issues trying to download the files. 我尝试了Werner的修复程序,但URL在尝试下载文件时遇到了问题。 Deleted Eclipse, and re-installed. 删除Eclipse,然后重新安装。 This appears to have fixed the issue. 这似乎解决了这个问题。

Actually - still having this issue, even after re-installing Eclipse... 实际上 - 即使在重新安装Eclipse之后仍然存在这个问题......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM