Type enum is not generic error cloning andengine

2019-08-02 23:50发布

问题:

I keep getting this error after cloning a repository from the AndEngine project..

The type Enum is not generic; it cannot be parameterized with arguments <BoundsSplit>

Here is the class where the error persists.

package org.andengine.util.spatial.adt.bounds; //The error points at the beginning of this line.
import org.andengine.util.exception.AndEngineException;

/**
 * (c) Zynga 2011
 *
 * @author Nicolas Gramlich <ngramlich@zynga.com>
 * @since 21:13:32 - 11.10.2011
 */
 public enum BoundsSplit {
// ===========================================================
// Elements
// ===========================================================

TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT;

// ===========================================================
// Constants
// ===========================================================

// ===========================================================
// Fields
// ===========================================================

// ===========================================================
// Constructors
// ===========================================================

// ===========================================================
// Getter & Setter
// ===========================================================

// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================

// ===========================================================
// Methods
// ===========================================================

// ===========================================================
// Inner and Anonymous Classes
// ===========================================================

public static class BoundsSplitException extends AndEngineException {
    // ===========================================================
    // Constants
    // ===========================================================

    private static final long serialVersionUID = 7970869239897412727L;

    // ===========================================================
    // Fields
    // ===========================================================

    // ===========================================================
    // Constructors
    // ===========================================================

    // ===========================================================
    // Getter & Setter
    // ===========================================================

    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    // ===========================================================
    // Methods
    // ===========================================================

    // ===========================================================
    // Inner and Anonymous Classes
    // ===========================================================
}

}

EDIT:

Here is more on what the error says

Multiple markers at this line
- The type java.lang.Enum cannot be resolved. It is indirectly referenced from 
 required .class files
- The type Enum is not generic; it cannot be parameterized with arguments 
 <BoundsSplit>
- The type java.lang.Object cannot be resolved. It is indirectly referenced from 
 required .class files
- The type java.lang.Enum cannot be resolved. It is indirectly referenced from 
 required .class files

回答1:

Well, it seems that this error has many causes. The main one from searching the web (Here) is that the .classpath file in the project directory is wrong - that's the one I had, too. It's probably AndEngine's project who has the wrong file, because you said this problem was encountered when you updated it.

So, you can either:

  1. Solve it. This page has a nice explanation of the problem, check it out. You can get more information here.
  2. Instead of importing AndEngine source into your workspace in eclipse (Which I guess you did, because that's probably the source of the problem), you can just link the source folder, then eclipse won't bug checking the AndEngine project files (Which might be wrong).

Another reason might be because of mis-configured JRE system library. There is a nice tutorial of how to fix that here.

By the way, this problem is related to eclipse, so I'll retag your question with eclipse tag, so if my answer won't help - at least you will get better ones :)