Error from Companion: java.lang.NoClassDefFoundError

On the Kodular Community a user had requested a proposal for a new extension using the Chromecast Java API/SDK. I wanted to do this and in a day I pretty much had it, until I tested it. I got a different error than what I’m getting now after building again and changing some things, but I continue to get this error:

Error from Companion: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/fasterxml/jackson/databind/ObjectMapper; & Error from Companion: java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/jmdns/ServiceListener; & Error from Companion: java.lang.NoClassDefFoundError: su.litvak.chromecast.api.v2.ChromeCasts; although I import import su.litvak.chromecast.api.v2.*; and in fact I did check the .jar with 7Zip and the class ChromeCasts.class is there.

If I try this with an APK, my app will crash. I am using Visual Studio Code and about half way through making the extension, it imported a most likely not Android class, related to JavaX. I removed it and built again, but I continue getting the same errors. I also set the Chromecast to null by default and I get this from my log:

[javac] warning: unknown enum constant Include.NON_NULL
    [javac]   reason: class file for com.fasterxml.jackson.annotation.JsonInclude$Include not found
    [javac] warning: unknown enum constant Include.NON_NULL
    [javac] warning: unknown enum constant Include.NON_NULL
    [javac] warning: unknown enum constant Include.NON_NULL

Is that related?

1 Like

The App Inventor extensions system doesn’t really handle transitive dependencies. If you’re getting class not found errors, then you typically have more JAR files that you need to pull in and include in the @UsesLibraries annotation. This would also explain the unknown enum warnings you’re seeing.

2 Likes

Actually you’re right. Looking back at the source of the Chromecast API, it does import something with javax which I didn’t expect, thinking it was that of VSC. In fact, it imports…

import javax.jmdns.JmDNS;
import javax.jmdns.ServiceInfo;

Thanks for the help! If I have any further issues, I will refer to the topic and let you know.

as this is a question concerning working with the App Inventor sources, I moved this thread into the #open-source-development catgorie

Taifun

Dependencies · vitalidze/chromecast-java-api-v2 · GitHub

@KodedScorpius I just found something that might be useful

@Alexander I am no longer working on this source or making it public.

Thank you,
Stay safe :heart:

1 Like