lundi 27 août 2018

Android Studio NativeActivity undefined reference to 'Input Queue hasEvents'

I have a native android studio project with native activity, I wanna handle input from the user so I use the following:

#include <android/input.h>
#include <android_native_app_glue.h>
#include <android/log.h>
#include "Game/Game.h"

#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "native- 
activity", __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "native- activity", __VA_ARGS__))

void AInputQueueCreated(ANativeActivity* activity,AInputQueue* queue){
    LOGW("InputQueue created: %p\n", queue);
    AInputEvent* event = NULL;
    while (AInputQueue_getEvent(queue, &event) >= 0) {
        //LOGW("New input event: type=%d\n", AInputEvent_getType(event));
    }
}
__attribute__((visibility("default")))
void ANativeActivity_onCreate(ANativeActivity* activity,void* savedState, 
size_t savedStateSize) {
    LOGW("Creating: %p\n", activity);
    activity->callbacks->onInputQueueCreated=AInputQueueCreated;
}

when i run this i get undefined reference to 'Input Queue hasEvents', if I remove AInputQueue_getEvent it runs without issues.

this is the CMakelists:

cmake_minimum_required(VERSION 3.4.1)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
                ${ANDROID_NDK}/sources/android/native_app_glue/
                src/main/jniLibs)

add_library( app-glue STATIC  
${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c )
add_library( cubat SHARED src/main/cpp/main.cpp )

find_library(log-lib log )

target_link_libraries( cubat app-glue ${log-lib} )

Aucun commentaire:

Enregistrer un commentaire