小编Rol*_*and的帖子

Android Honeycomb上的DexClassLoader

我正在研究一个试图通过DexClassLoader加载外部库的项目.这在2.3中非常有效:

    public class FormularDisplayLoader {
public final static String PATH ="/data/data/at.mSystem.client/files/mSystem_Client_FormularLibrary.jar";
        private DexClassLoader classLoader;

            public FormularDisplayLoader(Context context){
                    this.context = context;
                    this.classLoader = new DexClassLoader("/data/data/at.mSystem.client/
    files/mSystem_Client_FormularLibrary.jar",
                        context.getFilesDir().getAbsolutePath(),
                        null,
                        FormularDisplayLoader.class.getClassLoader());
            }

            public View getDisplay(String className) throws ErrorCodeException{
                    try {
                            Class c = classLoader.loadClass(className);
                            Method m = c.getMethod("getDisplay", Context.class);
                            View ret = (View) m.invoke(c.newInstance(), context);
                            return ret;
                    } catch (Exception e) {
                            e.printStackTrace();
                            throw new
    ErrorCodeException(FormularErrorCode.NO_DISPLAY_AVAILABLE_FOR_FORMULAR);
                    }
            }

    }
Run Code Online (Sandbox Code Playgroud)

不幸的是,当尝试将此应用程序移植到Honeycomb时(因为此应用程序的实际目标是平板电脑),DexClassLoader会抛出异常:

02-23 09:30:58.221: ERROR/dalvikvm(8022): Can't open dex cache '/data/
dalvik-cache/
data@d...@at.mSystem.client@files@mSystem_Client_FormularLibrary....@classes.dex':
No such file …
Run Code Online (Sandbox Code Playgroud)

android android-3.0-honeycomb

9
推荐指数
1
解决办法
3058
查看次数

标签 统计

android ×1

android-3.0-honeycomb ×1