I am trying to integrate the libusb library. I followed all the steps mentioned above, but still could not achieve.
What I've done:
- Follow the procedure in this link
- This helped me generate libusb1.0.so files for different ABIs.
- I have included these .SOs in my Android project under / src / main / jniLbs / AIBs / libusb 1.0.so
- Native-lib.cpp file created (see code below)
- Modified CMakeLists.txt (Editing purpose for using libusb functions inside my own lib by importing it "# include" libusb.h "" )
My native lib.cpp:
#include <jni.h> #include <string> #include "libusb.h" //**Getting error can not find libusb extern "C" JNIEXPORT jstring JNICALL Java_com_example_admin_usb_MainActivity_stringFromJNI( JNIEnv *env, jobject /* this */) { std::string hello = "Hello from C++"; return env->NewStringUTF(hello.c_str()); }
My CMakeLists.txt file:
What am I trying to achieve?
I want to use the libusb functions inside my native lib by importing "#include" libusb.h ". Therefore, I can use its function to detect usb and perform some operations.
Problem: Could not find libusb.h
The reason for updating the CMakeLists.txt file is because I want to transfer both the (native-lib and external library libusb.so) libraries to the APK and use libusb as an external library and its function inside my native cpp code ( But I donβt sure this is the right way to do this ).
I did not find the correct tutorial on integrating libusb into Android and fixed the documentation.
I think I do not have the CMakeLists.txt file.
Please correct me if I do something wrong.
source share