问题
I have a native vendor module built with AOSP (android 9.0.0_r35).
This module uses android/input.h
header. Note that this header is included in the android NDK.
When enabling the VNDK, building module fails with fatal error: 'android/input.h' file not found
error.
This is caused by android build system (see compiler.go) who does not export the CommonGlobalIncludes
when VNDK is enabled so frameworks/native/include (containing input.h) is not in include list.
I tried adding libandroid to LOCAL_SHARED_LIBRARIES without success. The android doc mentioning header does not refers to NDK includes. This file is supposed to stay stable so I think it is safe to use it from a vendor module.
Is there a module (LOCAL_SHARED_LIBRARIES or LOCAL_HEADER_LIBRARIES) to include to allow using NDK headers ?
Else, is it safe to add $(ANDROID_BUILD_TOP)/out/soong/ndk/sysroot/usr/include/
to include path ?
Test code : Android.mk :
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE:= testIncludeInput_vendor
LOCAL_PROPRIETARY_MODULE := true
LOCAL_SRC_FILES := test.cpp
LOCAL_SHARED_LIBRARIES := libandroid
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE:= testIncludeInput_system
LOCAL_SRC_FILES:= test.cpp
LOCAL_SHARED_LIBRARIES := libandroid
include $(BUILD_STATIC_LIBRARY)
test.cpp :
#include <android/input.h>
来源:https://stackoverflow.com/questions/62390189/using-ndk-header-when-building-vendor-module-with-vndk-enabled