Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load issues on Android since 1.5.4? #446

Closed
tmm1 opened this issue Dec 30, 2020 · 10 comments
Closed

load issues on Android since 1.5.4? #446

tmm1 opened this issue Dec 30, 2020 · 10 comments

Comments

@tmm1
Copy link
Contributor

tmm1 commented Dec 30, 2020

continuing discussion from #413 (comment)

seems to be more than just warnings for me, i'm not getting any javacpp functionality.

12-29 18:19:56.555 19941 19941 W System.err: Warning: Could not load Pointer: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.mock.jar", zip file "/system/framework/android.test.runner.jar", zip file "/mnt/expand/4bc1480a-802e-4602-9636-c9c878864962/app/app-xnWv8azJJ4Z1P1r3Wq3SZw==/base.apk"],nativeLibraryDirectories=[/mnt/expand/4bc1480a-802e-4602-9636-c9c878864962/app/app-xnWv8azJJ4Z1P1r3Wq3SZw==/lib/arm64, /mnt/expand/4bc1480a-802e-4602-9636-c9c878864962/app/app-xnWv8azJJ4Z1P1r3Wq3SZw==/base.apk!/lib/arm64-v8a, /system/lib64]]] couldn't find "libjnijavacpp.so"

Maybe the BufferPoolMXBean is unrelated and the problem is it is trying to look for libjnijavacpp.so? Is that file supposed to exist?

When I compile at the moment, I get a single libjniHDHRLib.so which includes jnijavacpp.cpp:

Info: Generating app/src/main/jniLibs/arm64-v8a/jnijavacpp.cpp
Info: Generating app/src/main/jniLibs/arm64-v8a/jniHDHRLib.cpp
Info: Compiling app/src/main/jniLibs/arm64-v8a/libjniHDHRLib.so
Info: ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android21-clang++ -Ivendor/dst/arm64/include -Ivendor/dst/arm/include app/src/main/jniLibs/arm64-v8a/jniHDHRLib.cpp app/src/main/jniLibs/arm64-v8a/jnijavacpp.cpp -O3 -s -ffast-math -Wl,-rpath,lib/ -D__ANDROID_API__=21 -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -march=armv8-a -Wall -nostdlib++ -fPIC -shared -Wl,--no-undefined -z text -o libjniHDHRLib.so -Wl,-soname,libjniHDHRLib.so -Lapp/src/main/jniLibs/arm64-v8a -lhdhomerun -llog -lc++_static -lc++abi -ldl -lm -lc
@saudet
Copy link
Member

saudet commented Dec 30, 2020

libjnijavacpp.so is just a warning too, you can ignore that one.

@tmm1
Copy link
Contributor Author

tmm1 commented Dec 30, 2020

Okay, I guess I am not used to all this noise on boot.

@saudet
Copy link
Member

saudet commented Dec 30, 2020

It's not noise, you might encounter this issue: bytedeco/javacv#1305

@tmm1
Copy link
Contributor Author

tmm1 commented Dec 30, 2020

So it would be preferable if I built and shipped a libjnijavacpp.so alongside the other libraries?

Maybe we should be using reflection to call PointerBufferPoolMXBean.register() here?
https://github.com/bytedeco/javacpp/blob/master/src/main/java/org/bytedeco/javacpp/Pointer.java#L515

Hmm, yea I think reflection might be the solution.

@saudet
Copy link
Member

saudet commented Dec 30, 2020

So it would be preferable if I built and shipped a libjnijavacpp.so alongside the other libraries?

If you don't need it in your application, no, it's not necessary. But if this is supposed to be a library, that might get used with other libraries, then users will use it with libjnijavacpp.so on their own, so you don't need to worry about it either way.

Maybe we should be using reflection to call PointerBufferPoolMXBean.register() here?
https://github.com/bytedeco/javacpp/blob/master/src/main/java/org/bytedeco/javacpp/Pointer.java#L515

Hmm, yea I think reflection might be the solution.

Yes, let's do that.

@tmm1
Copy link
Contributor Author

tmm1 commented Dec 30, 2020

If you don't need it in your application, no, it's not necessary.

Thanks. Is there any way to turn off the warnings in my app, perhaps with some sort of system property?

@saudet
Copy link
Member

saudet commented Dec 31, 2020 via email

@tmm1
Copy link
Contributor Author

tmm1 commented Dec 31, 2020

I think I'm missing something really simple here.. how do I generate the libjnijavacpp.so?

Currently I do the following to get a javacpp.jar, then I can use that to generate and compile the stubs for my custom preset:

$ git clone https://github.com/bytedeco/javacpp
$ cd javacpp
$ mvn install

$ javac -cp target/javacpp.jar /path/to/libcustom.java
$ java -jar target/javacpp.jar /path/to/libcustom
$ javac -cp target/javacpp.jar /path/to/libcustom.java /path/to/CustomLib.java

$ java -jar target/javacpp.jar /path/to/CustomLib -properties android-arm -d /path/to/jniLibs/arm
$ java -jar target/javacpp.jar /path/to/CustomLib -properties android-x86 -d /path/to/jniLibs/x86

All of that works just fine. Do I just need to repeat the same steps with src/main/java/org/bytedeco/javacpp/presets/javacpp.java?

@tmm1
Copy link
Contributor Author

tmm1 commented Dec 31, 2020

Do I just need to repeat the same steps with src/main/java/org/bytedeco/javacpp/presets/javacpp.java?

Looks like this is all you need:

$ java -jar target/javacpp.jar org/bytedeco/javacpp/presets/javacpp -d .
Info: Generating /javacpp/jnijavacpp.cpp
Info: Compiling /javacpp/org/bytedeco/javacpp/presets/macosx-x86_64/libjnijavacpp.dylib
Info: clang++ -I/Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home/include/darwin /javacpp/jnijavacpp.cpp -march=x86-64 -m64 -O3 -std=c++11 -arch x86_64 -Wl,-rpath,@loader_path/. -Wall -fPIC -pthread -dynamiclib -undefined dynamic_lookup -o libjnijavacpp.dylib
Info: Deleting /javacpp/jnijavacpp.cpp

@tmm1 tmm1 closed this as completed Dec 31, 2020
@saudet
Copy link
Member

saudet commented Dec 31, 2020

That works too I suppose, but it gets generated with the Maven build and
-Djavacpp.platform=android-arm, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants