I'd like to display webp image on older Android platforms. I tries these steps:
path
and set it in Eclipse preferences.Android Tools
-> Add native support
, confirm default name.libwebp-0.3.1.tar.gz
, extract to project/jni
static {}
and webpToBitmap
method to main Activity
, codes come from WebP for Android/jni/swig/libwebp.jar
(comes with libwebp source) to java build path and import com.google.webp.libwebp;
.And I got these errors when try to use webpToBitmap
: (delete unnecessary time/package name)
Could not find method com.google.webp.libwebp.WebPDecodeARGB, referenced from method ....MainActivity.webpToBitmap
VFY: unable to resolve static method 4601: Lcom/google/webp/libwebp;.WebPDecodeARGB
E/AndroidRuntime(12614): java.lang.UnsatisfiedLinkError: Couldn't load webp from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/....apk"],nativeLibraryDirectories=[/data/app-lib/..., /vendor/lib, /system/lib]]]: findLibrary returned null
I also tried add swig/libwebp_java_wrap.c \
(comes with libwebp source) to Android.mk
LOCAL_SRC_FILES
and include $(BUILD_STATIC_LIBRARY)
-> include $(BUILD_SHARED_LIBRARY)
, got same error.
Or, is there any prebuilt files I can easily add to my project?
Finally resolved this error by getting an updated version of the jar included in the 0.3.1 release. The one included in that package is broken and you can either use an old version from 0.3.0 or use the new version James has compiled at this link:
https://groups.google.com/a/webmproject.org/forum/#!topic/webp-discuss/4nNFdaE2GXI
To summarise:
This uses a slightly modified version of the 0.3.1 source tree. The libwebp.jar file wasn't working for that tree and we had to make some small modifications to the Android.mk files. Do the following changes to the files in the 0.3.1 release and grab the new libwebp.jar.
Add to Android.mk:
swig/libwebp_java_wrap.c \
-include $(BUILD_STATIC_LIBRARY)
+include $(BUILD_SHARED_LIBRARY)
LOCAL_ARM_MODE := arm
Application.mk should contain:
APP_ABI := armeabi armeabi-v7a
APP_OPTIM := release