NativeScript Android error: java.lang.Object com.tns.Runtime.callJSMethodNative
NativeScript Android error: java.lang.Object com.tns.Runtime.callJSMethodNative
我正在尝试为 android 添加支付库 (https://github.com/mayubao/Android-Pay),如下所示:
let activity = utils.ad.getApplicationContext();
let d = new Date().getMilliseconds();
let time = d.toString()
let wechatPayReq = new io.github.mayubao.pay_library.WechatPayReq.Builder()
.with(activity) //activity instance
.setAppId('wxd930ea5d5a258f4f') //wechat pay AppID
.setPartnerId("1900000109")//wechat pay partner id
.setPrepayId("1101000000140415649af9fc314aa427")//pre pay id
.setNonceStr("1101000000140429eb40476f8896f4c9")
.setTimeStamp(time)//time stamp
.setSign("7FFECB600D7157C5AA49810D2D8F28BC2811827B")//sign
.create();
//2. send the request with wechat pay
io.github.mayubao.pay_library.PayAPI.getInstance().sendPayRequest(wechatPayReq);
但我收到以下错误:
08-19 10:40:50.627 4706 4706 F art : art/runtime/java_vm_ext.cc:470] from java.lang.Object com.tns.Runtime.callJSMethodNative(int, int, java.lang.String, int, boolean, java.lang.Object[])
08-19 10:40:50.627 4706 4706 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethodNative(Native method)
08-19 10:40:50.627 4706 4706 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
08-19 10:40:50.627 4706 4706 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
08-19 10:40:50.627 4706 4706 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethod(Runtime.java:912)
08-19 10:40:50.627 4706 4706 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethod(Runtime.java:896)
08-19 10:40:50.627 4706 4706 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethod(Runtime.java:888)
08-19 10:40:50.695 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethodNative(Native method)
08-19 10:40:50.695 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
08-19 10:40:50.696 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
08-19 10:40:50.696 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:912)
08-19 10:40:50.696 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:896)
08-19 10:40:50.696 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:888)
08-19 10:40:50.698 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethodNative(Native method)
08-19 10:40:50.698 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
08-19 10:40:50.698 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
08-19 10:40:50.698 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:912)
08-19 10:40:50.698 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:896)
08-19 10:40:50.698 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:888)
环境:
tns --version
3.1.3
"tns-android": {
"version": "3.1.1"
}
我哪里做错了?请给我建议。提前致谢。
我试图传递 Activity 的 ApplicationContext。所以解决方案是:
import * as app from 'application';
let activity = app.android.foregroundActivity;
还要确保设备中安装了微信应用程序。
我正在尝试为 android 添加支付库 (https://github.com/mayubao/Android-Pay),如下所示:
let activity = utils.ad.getApplicationContext();
let d = new Date().getMilliseconds();
let time = d.toString()
let wechatPayReq = new io.github.mayubao.pay_library.WechatPayReq.Builder()
.with(activity) //activity instance
.setAppId('wxd930ea5d5a258f4f') //wechat pay AppID
.setPartnerId("1900000109")//wechat pay partner id
.setPrepayId("1101000000140415649af9fc314aa427")//pre pay id
.setNonceStr("1101000000140429eb40476f8896f4c9")
.setTimeStamp(time)//time stamp
.setSign("7FFECB600D7157C5AA49810D2D8F28BC2811827B")//sign
.create();
//2. send the request with wechat pay
io.github.mayubao.pay_library.PayAPI.getInstance().sendPayRequest(wechatPayReq);
但我收到以下错误:
08-19 10:40:50.627 4706 4706 F art : art/runtime/java_vm_ext.cc:470] from java.lang.Object com.tns.Runtime.callJSMethodNative(int, int, java.lang.String, int, boolean, java.lang.Object[])
08-19 10:40:50.627 4706 4706 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethodNative(Native method)
08-19 10:40:50.627 4706 4706 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
08-19 10:40:50.627 4706 4706 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
08-19 10:40:50.627 4706 4706 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethod(Runtime.java:912)
08-19 10:40:50.627 4706 4706 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethod(Runtime.java:896)
08-19 10:40:50.627 4706 4706 F art : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethod(Runtime.java:888)
08-19 10:40:50.695 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethodNative(Native method)
08-19 10:40:50.695 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
08-19 10:40:50.696 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
08-19 10:40:50.696 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:912)
08-19 10:40:50.696 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:896)
08-19 10:40:50.696 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:888)
08-19 10:40:50.698 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethodNative(Native method)
08-19 10:40:50.698 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
08-19 10:40:50.698 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
08-19 10:40:50.698 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:912)
08-19 10:40:50.698 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:896)
08-19 10:40:50.698 4706 4706 F art : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:888)
环境:
tns --version
3.1.3
"tns-android": {
"version": "3.1.1"
}
我哪里做错了?请给我建议。提前致谢。
我试图传递 Activity 的 ApplicationContext。所以解决方案是:
import * as app from 'application';
let activity = app.android.foregroundActivity;
还要确保设备中安装了微信应用程序。