Build successfully but got no method error

24 views
Skip to first unread message

Jeng-Ping Lin

unread,
Jun 5, 2017, 8:27:26 AM6/5/17
to App Inventor Open Source Development
     I tried to build extensions by first adding two simple methods "Muls" & "dd2".

These two methods could be correctly called from AI2. I then tried to add a third method "fvalue".

I rebuilt the extension and the extension was imported into a new project. I still could access the two

simple methods. I could see the method "fvalue" in the block screen. Bit when I tried to run my app

through the emulator, I got the following error

"Runtime Error
invoke: no method named `fvalue' in class org.comman.CalcTest<br/><i>Note:</i>&nbsp;You will not see another error reported for 5 seconds."

Could anyone advise me where the problem is, any suggestion appreciated.

-------------This is my method definition---------------------------
    @SimpleFunction(description = "test multi")
    public double Mul2(String x, String y) {
        return Double.parseDouble(x)*Double.parseDouble(y);
    }
   
    @SimpleFunction(description = "test div")
    public double dd2(String x, String y) {
        return Double.parseDouble(x)/Double.parseDouble(y);
    }
   
    @SimpleFunction(description = "test FV")
    public double fvalue(String r_s, String nper_s, String pmt_s, String pv_s, String type_s) {
        double r = Double.parseDouble(r_s) ;
        int nper = Integer.parseInt(nper_s);
        double pmt = Double.parseDouble(pmt_s) ;
        double pv = Double.parseDouble(pv_s) ;
        int type = Integer.parseInt(type_s);
        double fvalue = -(pv * Math.pow(1 + r, nper) + pmt * (1+r*type) * (Math.pow(1 + r, nper) - 1) / r);
        return fvalue;
    }


Evan Patton

unread,
Jun 5, 2017, 12:49:24 PM6/5/17
to App Inventor Open Source Development
Are you doing this using ai2.appinventor.mit.edu or ai2-test.appinventor.mit.edu? The former requires that you restart the companion as extensions are only sent at connection time. The latter should allow you to update extensions in place without having to restart the companion. As it stands, your companion still has the old version of the extension loaded, which is why it can't find the new method.

Evan

Jeng-Ping Lin

unread,
Jun 5, 2017, 6:43:30 PM6/5/17
to App Inventor Open Source Development
Thanks Evan. I'm using ai2.appinventor.mit.ed.I'll try ai2-test.appinventor.mit.edu next time.

Reply all
Reply to author
Forward
0 new messages