我为 Flex 做了一个本地扩展,效果很好。从 Flex 调用 Java 函数时,我得到了想要的结果。但是如果我想在 Java 中加载一个共享库,应用程序会在启动时崩溃。
加载库的代码:
public static void loadLibrary(String sLibName) {
try {
System.loadLibrary(sLibName);
} catch(UnsatisfiedLinkError e) {
(...)
@Override
public void initialize() {
// called when the native extension is ready to be used
Debug.info("Extension initialized");
loadLibrary("Native");
Logcat 给了我以下日志报告:
01-18 15:14:25.824: I/ColijnIT-AR(15349): Extension initialized
01-18 15:14:25.824: D/dalvikvm(15349): Trying to load lib /data/data/air.NativeJavaTest.debug/lib/libNative.so 0x41312378
01-18 15:14:25.834: D/dalvikvm(15349): Added shared lib /data/data/air.NativeJavaTest.debug/lib/libNative.so 0x41312378
01-18 15:14:25.834: W/System.err(15349): java.lang.NoClassDefFoundError: java/util/UUID
01-18 15:14:25.834: W/System.err(15349): at java.lang.Runtime.nativeLoad(Native Method)
01-18 15:14:25.834: W/System.err(15349): at java.lang.Runtime.loadLibrary(Runtime.java:368)
01-18 15:14:25.834: W/System.err(15349): at java.lang.System.loadLibrary(System.java:535)
如果我删除方法初始化中的 loadLibrary("Native") 调用,我不会收到任何错误,并且一切正常。但是当库成功完成加载并添加时(根据 logcat)它给了我 NoClassDefFoundError