0

I tried to make my own small calculator, but I don't want to make all the business logic by myself. So I tried to use the javax.script since I heard that the javax.script needs a real JVM and is a JavaScriptParser. Then, I searched for other libraries with the functions I needed and found the project "exp4j". First, I made a small normal Java Project with JDK 1.7, and yes, it works with the source code:

public static void main(String[] args) throws UnknownFunctionException, UnparsableExpressionException {
    ExpressionBuilder builder=new ExpressionBuilder("34*2");
    Calculable calc=builder.build();
    System.out.println(calc.calculate());
}

Then, I tried the same code in my model (MVC Pattern) of my calculator:

public void berechnen() throws UnknownFunctionException, UnparsableExpressionException {
    ExpressionBuilder builder=new ExpressionBuilder("34*2");
    Calculable calc=builder.build();
    setErgebnis(calc.calculate());
}

But every time I got the same exception:

"AndroidRuntime(630): java.lang.VerifyError",

after I started the app. I can't click on the button that runs the method berechnen() because the app crashes after I start it.

I'm confused why my program doesn't work. When I delete all imports of exp4j and delete the source for the calculation, my calculator works fine.

My only idea is that the exp4j libaries is using a class or method that does not exist in Android.

Thank you.

0xCursor
  • 2,242
  • 4
  • 15
  • 33
  • You may have include jars twice, check once in libs folder and libraries in properties, I have faced same in the past – Pragnani Apr 26 '13 at 15:58
  • Here is a screenshot. I think I dont have twice?! http://s1.directupload.net/images/130426/k7yytynt.jpg – user2324508 Apr 26 '13 at 16:05
  • Remove that in the libraries and paste freshly in your res/lib folder of android application project and then clear your project – Pragnani Apr 26 '13 at 16:08
  • Thank you ;) that worked. Sorry for that question, I dont used other libs since today. – user2324508 Apr 26 '13 at 16:13
  • I'll post answer, mark that as answer by clicking the right checkbox beside that answer. to help the others. – Pragnani Apr 26 '13 at 16:14

1 Answers1

3

You may have include jars twice, check once in libs folder and libraries in properties, I have faced same in the past What you need to do is to Remove that in the libraries and paste freshly in your res/lib folder of android application project and then clear your project

Pragnani
  • 20,075
  • 6
  • 49
  • 74