ndk-build doesn’t find hidraw.h for 32bit ABIs


I am trying to build a native app to communicate with a device over hidraw.

While trying to build app through ndk-build, I get following error:

jni/daemon.c:15:26: fatal error: linux/hidraw.h: No such file or directory
 #include <linux/hidraw.h>
compilation terminated.
make: *** [obj/local/armeabi-v7a/objs/hidrawdaemon/daemon.o] Error 1

Now, I checked with other ABIs, and I found that build fails for all 32 bit ABIs (armeabi-v7a armeabi x86 mips) but succeeds for all 64 bit ABIs (arm64-v8a x86_64 mips64)

I also checked that my ndk (r10e) contains hidraw.h for all available platforms:

gps@gps-HP-ProBook-4540s:~/Android/android-ndk-r10e/platforms/android-21$ ls
arch-arm  arch-arm64  arch-mips  arch-mips64  arch-x86  arch-x86_64
gps@gps-HP-ProBook-4540s:~/Android/android-ndk-r10e/platforms/android-21$ find . -name hidraw*

Can anyone point me to reason for build failure, and how to go about fixing this.


This seems like you’re targeting an older version of android than 21 – check what you’ve set as APP_PLATFORM in jni/Application.mk, or what is set in AndroidManifest.xml.

The reason why it’s failing only on 32 bit platforms, is that for the 64 bit platforms, android-21 is the first version where they’re supported at all, so if you target an older version, the 64 bit parts will still be built against android-21 headers and libs. (Similarly, x86 and mips were added in android-9.)

So in this case, since linux/hidraw.h is available only since android-21, make sure you set this as your minimum platform version.

Answered By – mstorsjo

Leave a Comment