hyperxpro/Brotli4j

Can't load native library

SettingDust opened this issue · 11 comments

It's throws a NullPointer at
https://github.com/hyperxpro/Brotli4j/blob/main/brotli4j/src/main/java/com/aayushatharva/brotli4j/Brotli4jLoader.java#L47.

The libPath is /lib/windows-x86_64/brotli.dll in debugger

Caused by the in is null and the Files#copy throw it.

    public static long copy(InputStream in, Path target, CopyOption... options)
        throws IOException
    {
        // ensure not null before opening file
        Objects.requireNonNull(in);

Tried adding natives as dependency.

I'm using Kotlin 1.5.21. OpenJDK 1.8.0.292-1.b10.
Windows 10 64bit

Which OS and Architecture?

Which OS and Architecture?

Edited

If you're using Gradle then you have to manually add the Windows native module.

Also, if possible, please share the code project to reproduce.

It's ok after add windows native manually. But the decompress status is ERROR. How can I debug?

Error status is generated due to invalid compressed data. Can you double check the compressed data?

Error status is generated due to invalid compressed data. Can you double check the compressed data?

Gotcha! Thanks!
I think we need a help for gradle in README. I try to write sth below. Haven't tested on other systems.

Kotlin DSL

    val brotliVersion = "1.5.0"
    implementation("com.aayushatharva.brotli4j:brotli4j:$brotliVersion")
    val operatingSystem = DefaultNativePlatform.getCurrentOperatingSystem()
    if (operatingSystem.isWindows) {
        implementation("com.aayushatharva.brotli4j:native-windows-x86_64:$brotliVersion")
    } else if (operatingSystem.isMacOsX) {
        implementation("com.aayushatharva.brotli4j:native-osx-x86_64:$brotliVersion")
    } else if (operatingSystem.isLinux) {
        if (DefaultNativePlatform.getCurrentArchitecture().isArm) {
            implementation("com.aayushatharva.brotli4j:native-linux-aarch64:$brotliVersion")
        } else {
            implementation("com.aayushatharva.brotli4j:native-linux-x86_64:$brotliVersion")
        }
    }

Can you please do a PR for this?

Can you please do a PR for this?

Okay :D

Pong...
Sorry, forget. Your lazy donkey is coming!