win15677335854 2015-07-12 07:52 采纳率: 33.3%
浏览 2539
已结题

java、Android和matlab混合编程问题 新手求助

大家帮忙看看,我将matlab中m文件打包成jar,引入jar包后在 java project能正常运行,
但在Android project就出错,具体错误信息:
FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at MotionBlur.DealMotionBlur.(DealMotionBlur.java:64)
at com.example.testcompilebetweenjavamatlab.MainActivity.testMatlab(MainActivity.java:115)
at com.example.testcompilebetweenjavamatlab.MainActivity.onCreate(MainActivity.java:51)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
...
Caused by: java.lang.VerifyError: com/mathworks/toolbox/javabuilder/internal/MWMCR
at MotionBlur.MotionBlurMCRFactory.(MotionBlurMCRFactory.java:131)

java中主要代码:
public static void main(String[] args) throws MWException{
//测试1 简单运算函数
Operation oper = new Operation();
Object[] result = null;
int a = 4;
int b = 10;

    //测试2    传递字符串
    PrintfName pn = new PrintfName();
    Object[] name = null; 

    //测试3  传递filename,matlab处理图片
    DealMotionBlur d = new DealMotionBlur();
    Object[] img = null;
    try {
        result = oper.operation(4,a,b);
        name = pn.PrintfName(1, "E:/temp_cropped7.jpg");
        img = d.MotionBlur(1, "E:/temp_cropped7.jpg");
    } catch (Exception e) {
        e.printStackTrace();
    }
}

Android application project中主要代码:
Object[] img = null;
try {

String name = "E:/temp_cropped7.jpg";
img = testMatlab(name);

} catch (MWException e) {
e.printStackTrace();
}

}
public static Object[] testMatlab(String filename) throws MWException {

    DealMotionBlur d = null;
    Object resultimg[] = null;
    try {
        d = new DealMotionBlur();
        resultimg = d.MotionBlur(1,filename);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return resultimg;           
}
  • 写回答

5条回答 默认 最新

  • 一杯苦茶 2015-07-13 08:25
    关注

    有些包在安卓中可能造成包名冲突,java中不会

    评论

报告相同问题?