导入的 Eclipse 项目未编译

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

Imported Eclipse projects not compiling

javaeclipsecordova

提问by Jon

I installed Eclipse 4.2 in new windows 8, and copied and imported all my projects. All projects are based on phonegap so have the phonegap build

我在新的 Windows 8 中安装了 Eclipse 4.2,并复制并导入了我的所有项目。所有项目都基于 phonegap,所以有 phonegap 构建

None will compile and all have red X by the src> app.java although they work fine in the original eclipse.

尽管它们在原始 eclipse 中工作正常,但没有人会编译并且所有的 src> app.java 都有红色的 X。

I dont understand the errors so dont know where to start:

我不明白错误所以不知道从哪里开始:

My Code: The error for the line in () not part of code

我的代码: () 中的行的错误不是代码的一部分

package com.x.x;
import android.os.Bundle;         (ERROR=The import android.os.Bundle cannot be resolved)
import com.phonegap.*;
public class App extends DroidGap {         (ERROR= The hierarchy of the type App is inconsistent)
/** Called when the activity is first created. */
@Override                       (ERROR = Override cannot be resolved to a type)
public void onCreate(Bundle savedInstanceState) {      (ERROR=Bundle cannot be resolved to a type)
    super.onCreate(savedInstanceState);
    super.loadUrl("file:///android_asset/www/index.html");   (ERROR = The method loadUrl(String) from the type DroidGap refers to the missing type String)
}
}

Error line 1:

错误行 1:

     Multiple markers at this line
- The type android.os.Bundle cannot be resolved. It is indirectly referenced from 
 required .class files
- The type android.content.Intent cannot be resolved. It is indirectly referenced from 
 required .class files
- The type java.lang.String cannot be resolved. It is indirectly referenced from 
 required .class files
- The type java.lang.Object cannot be resolved. It is indirectly referenced from 
 required .class files

回答by Marko Topolnik

Step one is to resolve your JRE setup, which is obviously not in order (java.lang.Objectcannot be resolved). Open project properties, Java Build Path, Libraries, and in the list find the item referring to the JRE. Edit this entry. You will probably need to locate the JRE on your filesystem.

第一步是解决你的JRE设置,这显然不正常(java.lang.Object无法解决)。打开项目属性、Java 构建路径、库,然后在列表中找到引用 JRE 的项目。编辑此条目。您可能需要在文件系统上找到 JRE。

回答by Ranjani

I resolved by following this steps.. open project properties, java build path, libraries, search for JRE, select that and remove JRE, click on add libraries, select JRE system libraries, click next and check both execution environment and alternative jre than click on finish. Now again open project than select clean. This will clean your project.

我按照这个步骤解决了..打开项目属性,java构建路径,库,搜索JRE,选择并删除JRE,点击添加库,选择JRE系统库,点击下一步并检查执行环境和替代jre,然后点击在完成。现在再次打开项目而不是选择干净。这将清理您的项目。

回答by Deepa Chhetri

Try this:

尝试这个:

  1. Right click on package > Build Path > Configure Build Path
  2. Select Java Build Path > click on Classpath, remove the existing JRE libraries.
  3. Add Library > JRE system library > Alternate JRE > Installed JRE > Add > Standard VM > Browse the jre folder and point JRE Home to that directory where you installed JRE > Finish.
  1. 右键单击包>构建路径>配置构建路径
  2. 选择 Java Build Path > 单击 Classpath,删除现有的 JRE 库。
  3. 添加库 > JRE 系统库 > 备用 JRE > 已安装的 JRE > 添加 > 标准 VM > 浏览 jre 文件夹并将 JRE 主页指向您安装 JRE 的目录 > 完成。

This should fix the problem.

这应该可以解决问题。

回答by Techie Manoj

Just go to the compile setting and check project specific setting and then change the compiler version. This can be resolved from there.

只需转到编译设置并检查项目特定设置,然后更改编译器版本。这可以从那里解决。

回答by Rani Kheir

I had the same errors on my project, but I fixed it in a different way, here's what I did:

我在我的项目中遇到了同样的错误,但我以不同的方式修复了它,这是我所做的:

  • Right clicked my android project (the root) and selected Properties
  • Clicked on 'Android' on the list towards the left
  • Ticked an Android Build from the Build Target list, like Android #.#.# (Android 4.0.3 for example)
  • 右键单击我的 android 项目(根)并选择属性
  • 单击左侧列表中的“Android”
  • 从 Build Target 列表中勾选一个 Android Build,例如 Android #.#.#(例如 Android 4.0.3)

Clicked okay and that was it! Cleared all my errors :)

单击确定,就是这样!清除了我所有的错误:)