我正在尝试使用处理视频 2.2.1 作为我(Scala)项目中的库。我可以直接在 Processing IDE 中运行演示捕获草图,但是从我的项目中我得到一个看起来像版本不匹配的错误:

Exception in thread "Animation Thread" java.lang.AbstractMethodError: com.sun.jna.Structure.getFieldOrder()Ljava/util/List;
    at com.sun.jna.Structure.fieldOrder(Structure.java:868)
    at com.sun.jna.Structure.getFields(Structure.java:894)
    at com.sun.jna.Structure.deriveLayout(Structure.java:1042)
    at com.sun.jna.Structure.calculateSize(Structure.java:966)
    at com.sun.jna.Structure.calculateSize(Structure.java:933)
    at com.sun.jna.Structure.allocateMemory(Structure.java:360)
    at com.sun.jna.Structure.<init>(Structure.java:184)
    at com.sun.jna.Structure.<init>(Structure.java:172)
    at com.sun.jna.Structure.<init>(Structure.java:159)
    at com.sun.jna.Structure.<init>(Structure.java:151)
    at org.gstreamer.lowlevel.GObjectAPI$GTypeInstance.<init>(GObjectAPI.java:114)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at java.lang.Class.newInstance(Class.java:442)
    at com.sun.jna.Structure.newInstance(Structure.java:1635)
    at com.sun.jna.Structure.newInstance(Structure.java:1621)
    at com.sun.jna.Structure.size(Structure.java:950)
    at com.sun.jna.Native.getNativeSize(Native.java:1076)
    at com.sun.jna.Structure.getNativeSize(Structure.java:1927)
    at com.sun.jna.Structure.getNativeSize(Structure.java:1920)
    at com.sun.jna.Structure.validateField(Structure.java:1018)
    at com.sun.jna.Structure.validateFields(Structure.java:1032)
    at com.sun.jna.Structure.<init>(Structure.java:179)
    at com.sun.jna.Structure.<init>(Structure.java:172)
    at com.sun.jna.Structure.<init>(Structure.java:159)
    at com.sun.jna.Structure.<init>(Structure.java:151)
    at org.gstreamer.lowlevel.GObjectAPI$GParamSpec.<init>(GObjectAPI.java:395)
    at org.gstreamer.GObject.findProperty(GObject.java:656)
    at org.gstreamer.GObject.set(GObject.java:87)
    at processing.video.Capture.initGStreamer(Unknown Source)
    at processing.video.Capture.<init>(Unknown Source)
    at (my sketch)

Maven POM 文件是 here 。我最终在类路径上得到以下库:
  • com.googlecode.gstreamer-java:gstreamer-java:1.5
  • net.java.dev.jna:jna:4.0.0
  • net.java.dev.jna:platform:3.4.0
  • org.processing:core:2.2.1
  • org.processing:video:2.2.1

  • 我的直觉是 jna 和平台之间存在不匹配 - 它们应该具有相同的版本吗?这表明发布的 POM 是错误的。处理独立使用哪个版本?不幸的是,那里的 jar 没有版本信息。

    最佳答案

    事实上,处理 POM 似乎指定了一个不兼容的 JNA 版本。在 sbt 中,我可以使用 dependencyOverrides 声明来解决这个问题:

    def processingVersion  = "2.2.1"
    def gstreamerVersion   = "1.5"
    def jnaVersion         = "3.4.0"
    
    libraryDependencies ++= Seq(
      "org.processing" % "video" % processingVersion,
      "com.googlecode.gstreamer-java" % "gstreamer-java" % gstreamerVersion
    )
    
    dependencyOverrides += "net.java.dev.jna" % "jna" % jnaVersion // !
    

    关于处理 2.2.1 视频 - AbstractMethodError - GStreamer/JNA 不匹配?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32597488/

    10-13 02:35