devopvoid / webrtc-java

WebRTC for desktop platforms running Java
Apache License 2.0
248 stars 60 forks source link

0.4.0 and later versions throw an error when the native library is loaded; 0.3.0 does not #95

Closed doctorpangloss closed 1 year ago

doctorpangloss commented 1 year ago

Describe the bug Loading the native library throws a NoSuchMethodError.

Accept this is a real exception. This is probably related to something being more strictly enforced in Java 17 (the version I'm using) or specifically GraalVM. But I think you will need to build the native artifacts anew.

To Reproduce Steps to reproduce the behavior:

  1. Add the following dependencies to your build.gradle

    testImplementation "dev.onvoid.webrtc:webrtc-java:0.3.0"
    testImplementation "dev.onvoid.webrtc:webrtc-java-windows-x86_64:0.1.0"
    testImplementation "dev.onvoid.webrtc:webrtc-java-macos-x86_64:0.1.0"
    testImplementation "dev.onvoid.webrtc:webrtc-java-linux-x86_64:0.1.0"
  2. Create a test of the form var t = new PeerConnectionFactory().

  3. Observe no issues.

  4. Change your dependencies to the following:

    testImplementation "dev.onvoid.webrtc:webrtc-java:0.7.0"
    testImplementation "dev.onvoid.webrtc:webrtc-java-windows-x86_64:0.1.0"
    testImplementation "dev.onvoid.webrtc:webrtc-java-macos-x86_64:0.1.0"
    testImplementation "dev.onvoid.webrtc:webrtc-java-linux-x86_64:0.1.0"
  5. Run the test.

  6. Observe the error:

    java.lang.NoSuchMethodError: Ldev/onvoid/webrtc/media/audio/AudioSource;.<init>()V
    at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
    at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:388)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:232)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:174)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2389)
    at java.base/java.lang.Runtime.load0(Runtime.java:755)
    at java.base/java.lang.System.load(System.java:1953)
    at dev.onvoid.webrtc.internal.NativeLoader.loadLibrary(NativeLoader.java:71)
    at dev.onvoid.webrtc.PeerConnectionFactory.<clinit>(PeerConnectionFactory.java:42)
  7. Observe that 0.3.0 is the last version where AudioSource was a class and not an interface.

  8. Observe that all versions 0.4.0 through 0.7.0 are affected.

Expected behavior The latest version of the library should work with the native artifacts.

Desktop (please complete the following information):

Additional context

openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment GraalVM CE 22.1.0 (build 17.0.3+7-jvmci-22.1-b06)
OpenJDK 64-Bit Server VM GraalVM CE 22.1.0 (build 17.0.3+7-jvmci-22.1-b06, mixed mode, sharing)
devopvoid commented 1 year ago

Hi, thanks for the report. I think you have a problem with the version(s) of the native library.

"dev.onvoid.webrtc:webrtc-java:0.7.0"
"dev.onvoid.webrtc:webrtc-java-windows-x86_64:0.1.0" << must be the same version as of webrtc-java
"dev.onvoid.webrtc:webrtc-java-macos-x86_64:0.1.0"
"dev.onvoid.webrtc:webrtc-java-linux-x86_64:0.1.0"
doctorpangloss commented 1 year ago

No other versions besides 0.1.0 exist on Maven and Jitpack.

Hi, thanks for the report. I think you have a problem with the version(s) of the native library.

"dev.onvoid.webrtc:webrtc-java:0.7.0"
"dev.onvoid.webrtc:webrtc-java-windows-x86_64:0.1.0" << must be the same version as of webrtc-java
"dev.onvoid.webrtc:webrtc-java-macos-x86_64:0.1.0"
"dev.onvoid.webrtc:webrtc-java-linux-x86_64:0.1.0"
> Could not resolve all files for configuration ':my-project:testCompileClasspath'.
   > Could not find dev.onvoid.webrtc:webrtc-java-windows-x86_64:0.7.0.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/dev/onvoid/webrtc/webrtc-java-windows-x86_64/0.7.0/webrtc-java-windows-x86_64-0.7.0.pom
       - https://jitpack.io/dev/onvoid/webrtc/webrtc-java-windows-x86_64/0.7.0/webrtc-java-windows-x86_64-0.7.0.pom
     Required by:
         project :my-project
   > Could not find dev.onvoid.webrtc:webrtc-java-macos-x86_64:0.7.0.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/dev/onvoid/webrtc/webrtc-java-macos-x86_64/0.7.0/webrtc-java-macos-x86_64-0.7.0.pom
       - https://jitpack.io/dev/onvoid/webrtc/webrtc-java-macos-x86_64/0.7.0/webrtc-java-macos-x86_64-0.7.0.pom
     Required by:
         project :my-project
   > Could not find dev.onvoid.webrtc:webrtc-java-linux-x86_64:0.7.0.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/dev/onvoid/webrtc/webrtc-java-linux-x86_64/0.7.0/webrtc-java-linux-x86_64-0.7.0.pom
       - https://jitpack.io/dev/onvoid/webrtc/webrtc-java-linux-x86_64/0.7.0/webrtc-java-linux-x86_64-0.7.0.pom
     Required by:
         project :my-project
doctorpangloss commented 1 year ago
  testImplementation "dev.onvoid.webrtc:webrtc-java:0.7.0"
  testImplementation group: "dev.onvoid.webrtc", name: "webrtc-java", version: "0.7.0", classifier: "windows-x86_64"
  testImplementation group: "dev.onvoid.webrtc", name: "webrtc-java", version: "0.7.0", classifier: "macos-x86_64"
  testImplementation group: "dev.onvoid.webrtc", name: "webrtc-java", version: "0.7.0", classifier: "linux-x86_64"

works