1

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!

arastirmaci
  • 103
  • 1
  • 1
  • 8

1 Answers1

0

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.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • Thanks! "Update Client Libs" worked. However, I needed to do "Update Client Libs" individually for all my projects (it downloaded the libs for each project and allowed me to run). Is there a way to do it just once for all codenameone projects? – arastirmaci Jan 20 '16 at 09:17
  • Yes if you need to use something new that isn't in your current version. Notice that the latest version is automatically updated every time you send a build (assuming there is a new version). You can just copy the jars from the project to all your other projects and set the libVersion in the codenameone_settings.properties to avoid that behavior. – Shai Almog Jan 21 '16 at 04:11