简体   繁体   中英

invalid “Unresolved compilation problems” in codenameone

I have invalid "unresolved compilation problems" in codenameone:

The project has valid syntax and works fine on other systems.

However, on my system, I have strange compilation errors... It says that the specified function is undefined, but actually it is defined. Here is one example:

For the following code line:

Container c = new Container();
Label l = new Label ("label");
c.add(l);

(I import com.codename1.ui.Container and import com.codename1.ui.Label)

I get the following error:

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.codename1.impl.javase.Executor$1$1.run(Executor.java:100)
    at com.codename1.ui.Display.processSerialCalls(Display.java:1144)
    at com.codename1.ui.Display.mainEDTLoop(Display.java:963)
    at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
    at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
Caused by: java.lang.Error: Unresolved compilation problem: 
    The method add(Label) is undefined for the type Container

    at com.mycompany.hi.HiWorld.start(HiWorld.java:53)
    ... 9 more

It compiles fine if I change c.add(l) to c.addComponent(l).

I have the latest version of codenameone (1.0.0.201511241324) and java jdk (jdk1.8.0_65).

Thanks!

I'm assuming that this is an old project? Did you change the classpath in any way?

Did you use versioned build ?

If so that would install an older version of the libraries temporarily.

add was a method that was added in the past couple of months (before that we only had addComponent . So if you built against an older version it would have failed.

You can go to project properties, in the Codename One section press the "Update Client Libs" button then refresh the project. This should either trigger an error on add if you use the versioned build or allow you to run.

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