Android Platform has an utility class that's used to take android screenshot . I copied "ScreenCap.cpp" in to JNI folder then build via NDK but failed. The NDK compiler didn't find needed libraries:
#include <binder/IMemory.h>
#include <gui/SurfaceComposerClient.h>
#include <SkImageEncoder.h>
#include <SkBitmap.h>
#include <SkData.h>
#include <SkStream.h>
Here is error log:
jni/ScreenCap.cpp:28:28: fatal error: SkImageEncoder.h: No such file or directory
compilation terminated.
Please tell me how to fix this.
BTW, Is there any solution to capture entire android screen programmatically? I need to capture it at least 10 times per second.
Thanks.
This question is quite old but I'll try to help just in case.
The problem is that SkImageEncoder.h is not part from NDK but from system's libskia library (not available in the NDK) and, then, should be build together with full system's build process.
If you want this application to run in single device, e.g. you personal device, you should be able to create a working binary by modifying your Android.mk file:
include $(CLEAR_VARS)
LOCAL_MODULE := system_libskia
LOCAL_SRC_FILES := PATH_TO_LIBSKIA/libskia.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := PATH_TO_SKIA_INCLUDE_FOLDER
LOCAL_SHARED_LIBRARIES := system_libskia
You can obtain your device's libskia.so by using running:
adb pull /system/lib/libskia.so
Another possible, but ugly, workaround would be loading libskia.so through dlopen and, then, read all needed symbols from it. This would work for any device as long as symbol's signature remains the same.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With