简体   繁体   中英

Imported Eclipse projects not compiling

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

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

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:

     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

Step one is to resolve your JRE setup, which is obviously not in order ( java.lang.Object cannot 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.

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.

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

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)

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

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.

This should fix the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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