I want my library to depend on the Video library, but I get loading conflicts

I am creating a library that I want to depend on the Video library. IE I want my library to instantiate a Capture and read video frames. I started from the library template. I placed the Video library's jars in the lib folder, then built with Ant.

I can then run examples from my library just fine. But I also have the Video library installed in my Sketchbook libraries folder, as most people do. When I try to run these examples I get the error:

More than one library is competing for this sketch. The import processing.video points to multiple libraries:
Video (/Users/andrew/Documents/Processing3/libraries/video) Art Screen 
(/Users/andrew/Documents/Processing3/libraries/ArtScreen) Extra libraries need to be
removed before this sketch can be used.

I could of course delete the Video library from my Sketchbook libraries folder, but this would be annoying to ask users of my library to do. Is this the only solution? Are there any examples of libraries people have built that depend on other Processing libraries? What is the best practice here? Should we just never write libraries that depend on other Processing libraries?

Thanks,

Andrew

Library source is here

Answers

  • edited April 2017

    Got no experience in creating libraries, so it's just blind guesses here. 3:-O

    In general I guess, when a library explicitly use import, there's a high probability when it's compiled, it may drag those other libraries into its ".jar" together! :-SS

    You should look up your library's ".jar" and check whether there are ".class" files related to the video library. #:-S

    Maybe if you forcibly delete them from the ".jar", it's gonna force your library to use them from PDE's "/libraries" folder. :ar!

  • GoToLoop,

    Thanks!

    So I had not actually been including the .class files in my jar. I had been including the video.jar (and natives) alongside my jar in the library zip file.

    I tried removing these jars from the final zip, IE, from my library that was installed in the Sketchbook/libraries folder. Initially, this did not work, running examples from my library I would then get: ClassNotFoundException: processing.video.Capture.

    I then added the import statement for video at the top of my Sketches and got them working.

    import artscreen.*;
    import processing.video.*;
    

    So I think this is definitely a workable solution. I think I could automate this with the exports.txt file for the Ant build.

    Andrew

Sign In or Register to comment.