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

hid4java Android #83

Closed
Chakib-Temal opened this issue Nov 7, 2019 · 8 comments
Closed

hid4java Android #83

Chakib-Temal opened this issue Nov 7, 2019 · 8 comments
Assignees

Comments

@Chakib-Temal
Copy link

Hi i try to implement this library in an Android OS

to add the depo maven in build.gradle (module:app)

dependencies {
compile 'org.hid4java:hid4java:0.5.0'
}
when the execution is in this line
HidServices hidServices = HidManager.getHidServices(hidServicesSpecification);

i have an exception :
Caused by: org.hid4java.HidException: Hidapi did not initialise: Native library (com/sun/jna/android-arm/libjnidispatch.so) not found in resource path (.)

have you a solution ? an idea ? thank u

@gary-rowe
Copy link
Owner

At present Android isn't supported. I'm considering it for the latest 0.6.0 release which has some newer native libraries.

If you'd like to try compiling hidapi native libraries for your platform there are enhanced instructions on the develop branch. Obviously, if you want it included in the final release, let me know how you get on here on this issue.

@gary-rowe gary-rowe added this to the Release 0.6.0 milestone Nov 7, 2019
@Chakib-Temal
Copy link
Author

have you any idea ? how to start ?

@gary-rowe
Copy link
Owner

I had a quick look at it earlier today using dockcross. Essentially you'll need to do the following:

  1. Take a look at the README.md in the develop branch of this project under compiling for different platforms.
  2. Examine the build-hidapi.sh for Android to see my (failed) attempts to get it working.
  3. Install Docker, dockcross etc to get your virtual build environment up and running.
  4. Attempt to cross-compile the hidapi native library for arm64. (You may need to fiddle with the ./configure --host=<something> command to get it to work). I reached a barrier with librt.so being missing for the aarch64 compiler.

As you can see it's quite complex and you may find it easier to compile hidapi on an Android machine using a native compiler. See the README.md in this project for a link to the libusb/hidapi project so you can git clone it and follow its build instructions.

I may get some time next week to look at this but hopefully the above will get you started.

@Chakib-Temal
Copy link
Author

I had a quick look at it earlier today using dockcross. Essentially you'll need to do the following:

  1. Take a look at the README.md in the develop branch of this project under compiling for different platforms.
  2. Examine the build-hidapi.sh for Android to see my (failed) attempts to get it working.
  3. Install Docker, dockcross etc to get your virtual build environment up and running.
  4. Attempt to cross-compile the hidapi native library for arm64. (You may need to fiddle with the ./configure --host=<something> command to get it to work). I reached a barrier with librt.so being missing for the aarch64 compiler.

As you can see it's quite complex and you may find it easier to compile hidapi on an Android machine using a native compiler. See the README.md in this project for a link to the libusb/hidapi project so you can git clone it and follow its build instructions.

I may get some time next week to look at this but hopefully the above will get you started.

it's seems hard to implement, i tried with the standard library android UsbManager
i send the message but the device didn't answer me

result = connection.controlTransfer(0x21,0x09,0x0200,0x00, bytes, bytes.length,2000);

it's seems the same function used in the C native library that you used for your library

using your library , the parameters of this functions are writen automatically, now i don't know how to catch all this parameters from the log of C library (may be i can reproduce it with the android sdk standard)

parameters are :
requestType
request
value
index
buffer[]
lenght of buffer
timeout

i don't really understand the 4 first parameters

how can i debog the C library to follow the logout of all parameters just before the send ?

@Chakib-Temal
Copy link
Author

it will be very nice if you can do the same thing for Android OS

@gary-rowe gary-rowe self-assigned this Jul 1, 2020
@gary-rowe gary-rowe added the in progress This issue is under active development in the develop branch or a feature label Jul 1, 2020
@gary-rowe
Copy link
Owner

I have some more time to work on hid4java these days so I'll see about getting Android working within the cross-compilation toolset.

@Chakib-Temal
Copy link
Author

I have some more time to work on hid4java these days so I'll see about getting Android working within the cross-compilation toolset.

you don't need to develop anything on android

here is a class for HidDriver (example) with Android SDK
HidDriverForAndroid

@gary-rowe
Copy link
Owner

Thanks, Chakib. That code looks ideal for Android developers to use and makes a lot more sense than having a dedicated HID library. I'll mark this as closed and remove Android support as a requirement.

@gary-rowe gary-rowe removed the in progress This issue is under active development in the develop branch or a feature label Jul 2, 2020
@gary-rowe gary-rowe removed this from the Release 0.6.0 milestone Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants