Domanda

I'd like to display webp image on older Android platforms. I tries these steps:

  1. Download latest Android SDK and NDK package.
  2. Add NDK path to system environment path and set it in Eclipse preferences.
  3. Create new Android project in Eclipse
  4. Right click on project folder, Android Tools -> Add native support, confirm default name.
  5. Download libwebp-0.3.1.tar.gz, extract to project/jni
  6. Add static {} and webpToBitmap method to main Activity, codes come from WebP for Android
  7. Add /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?

È stato utile?

Soluzione

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    
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top