Online Android build NoClassDefFoundError for build.xml

69 views
Skip to first unread message

P5music

unread,
Jan 21, 2021, 5:34:07 AM1/21/21
to CodenameOne Discussions
As my CodenameOne version of my app is finished, I am curious to see if it works on real devices.
I want to test on Android first but I get this kind of errors when I request the Android online build:
C:\Users\myname\IdeaProjects\myapp\build.xml:532: java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/sun/xml/bind/v2/model/annotation/AnnotationReader

I had a similar error in the first attempt.
I had some Java classes that were not used, so I removed them from the project and I tried again,
to get only an error about the build.xml file generated code portion having been removed or changed, or something similar.
Then I rebuild the project and invalidated/restart the IDE
to have the reported error above.
When I open the build.xml file there are some parameters in error (red color)
like
codename1.version, codename1.ios.appid, selectedOfflineBuilder and so on (25 issues)
Is it JDK8 that is needed?
I use JDK11 that seems to be supported, although in the developer guide JDK8 is mentioned as a pre-requisite for Android builds.

Thanks in advance

Hannah R

unread,
Jan 21, 2021, 9:19:31 AM1/21/21
to CodenameOne Discussions

P5music

unread,
Jan 21, 2021, 10:30:55 AM1/21/21
to CodenameOne Discussions
Hello,
If I execute 
java -version
in the MSDOS prompt I get
java version "15.0.1" 2020-10-20
Java(TM) SE Runtime Environment (build 15.0.1+9-18)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)
Is it wrong?
I could not install 11 because I cannot access the Oracle login.
I did not understand what is 1.8. Do you mean 11.1.8?
And also, what is the IDEA counterpart of netbeans.conf?
Thanks

Hannah R

unread,
Jan 21, 2021, 10:55:42 AM1/21/21
to CodenameOne Discussions
Per my understanding it has nothing to do with java version on your computer.
What I did, I changed my Project SDK from 11 to 1.8  in my IntelliJ Project Structure Settings :
ps.png    
ps1.png

P5music

unread,
Jan 22, 2021, 4:27:38 AM1/22/21
to CodenameOne Discussions
Thanks, 
Sorry but I do not understand.
That's a very old version of JDK, why should I use it for my project?
You may refer to OpenJDK, indeed I found Microsoft OpenJDK 1.8 on my system from VisualStudio I think. Is it a different nomenclature?
I set it in the project settings and
invalidated/restart, recompiled, send Android build
but
the build.xml is still in error,
the output is different, that AnnotationReader error is gone but there are 3 unnamed errors for the build.xml and all those parameters are red in that file.
I got also many warning about syntactic nuances.
What can be done now?
Regards


Shai Almog

unread,
Jan 22, 2021, 5:36:24 AM1/22/21
to CodenameOne Discussions
JDK 9 broke a lot of things. JDK 8 is still the most commonly used JDK because of that.
This is specifically a workaround to a problem with JAXB which is used in one place in our build process. We hope to remove that specific usage which will remove the need for that workaround.

Hannah R

unread,
Jan 22, 2021, 5:47:12 AM1/22/21
to codenameone...@googlegroups.com
1.8 is not an old JDK. It's just how they name it. https://www.quora.com/Do-Java-1-8-and-Java-8-refer-to-the-same-thing
You need to share a log or screenshot of your new errors. 


--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/fTucb1Z5_zc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/e816013a-2f1a-48fc-b33c-d59335b14c91n%40googlegroups.com.

P5music

unread,
Jan 22, 2021, 6:06:18 AM1/22/21
to CodenameOne Discussions
I get many strange warnings like

C:\Users\myname\IdeaProjects\myapp\src\com\myapp\app\MyClass.java:30: error: cannot find symbol
File f = new File(something);
^

or
import java.util.concurrent.CountDownLatch;
                 ^

or
        latch=new CountDownLatch(1);
              ^

or also
error: type WeakReference does not take parameters
or
error: incompatible types: String cannot be converted to char
and so on. (It's a very long list, the IDE does not let me copy its entire text)

Regards

Hannah R

unread,
Jan 22, 2021, 7:06:17 AM1/22/21
to CodenameOne Discussions
I can't say for all of those errors, but some of them you definitely must fix (like  incompatible types: String cannot be converted to char  or  java.util.concurrent.CountDownLatch;   -- it's might be not supported by codename one) . Your code could be ran smoothly in the simulator, but for Android build there is all another process and some things might be not supported (for example  CountDownLatch  -- Shai will know better if it's supported or not). So you need to find a way what to change it to. 

P5music

unread,
Jan 22, 2021, 10:28:35 AM1/22/21
to CodenameOne Discussions
And what about the many build.xml parameters in red that produce the 3 errors?

Hannah R

unread,
Jan 22, 2021, 11:01:42 AM1/22/21
to CodenameOne Discussions
You need to fix those errors in your code (use some other classes to achieve your goal), then your build will be successful. 

P5music

unread,
Jan 22, 2021, 1:05:59 PM1/22/21
to CodenameOne Discussions
It's so strange because the red parameters in the build.xml file are totally unrelated to my source code.
However source problems seem to be related to File, WeakReference (does not like <T>), string.replaceFirst, replace, replaceALL (does not like the double quotes for chars?), CountDownLatch, BufferedReader.
Do you confirm those are not compatible with CoenameOne?
Thanks

Shai Almog

unread,
Jan 23, 2021, 1:10:15 AM1/23/21
to CodenameOne Discussions
They aren't. You can see which APIs are supported by looking in our Javadocs https://www.codenameone.com/javadoc/
Reply all
Reply to author
Forward
0 new messages