javascript - ClassNotFoundException in NativeScript using .extend() -
i trying extend googleapiclient.connectioncallbacks(), keep getting error
`java.lang.runtimeexception: unable start activity componentinfo{org.nativescript.samplegroceries/com.tns.nativescriptactivity}: com.tns.nativescriptexception: calling js method oncreate failed
error calling module function
error: java.lang.classnotfoundexception: com.google.android.gms.common.api.googleapiclient_connectioncallbacks java.lang.class.classforname(native method) java.lang.class.forname(class.java:324) java.lang.class.forname(class.java:285) com.tns.dexfactory.generatedex(dexfactory.java:262) com.tns.dexfactory.resolveclass(dexfactory.java:120) com.tns.classresolver.resolveclass(classresolver.java:45)
`
my corresponding code is
var googleapiclient = com.google.android.gms.common.api.googleapiclient; var myconnectioncallbacks = googleapiclient.connectioncallbacks.extend({ onconnected: function(connectionhint){ var messagelistener = messagelistener.extend({ onfound: function(message){ log.d("message", "found message :) "); }, onlost: function(message){ log.d("message", "lost message :( "); } }); var mmessagelistener = new messagelistener(); }, onconnectionsuspended: function(){} }); var messagesoptionsbuilder = new com.google.android.gms.nearby.messages.messagesoptions.builder().setpermissions(nearbypermissions.ble).build(); var test = new googleapiclient.builder(context).addapi(nearby.messages_api, messagesoptionsbuilder); test.addconnectioncallbacks(new myconnectioncallbacks(this));
maybe misunderstood docs? https://docs.nativescript.org/runtimes/android/generator/extend-class-interface
edit: why there underscore in error log after googleapiclient?
any suggestions wrong?
the problem here trying extend interface wrong . more info -> https://docs.nativescript.org/runtimes/android/generator/extend-class-interface#interfaces
var messagesoptionsbuilder = new com.google.android.gms.nearby.messages.messagesoptions.builder().setpermissions(nearbypermissions.ble).build(); var test = new googleapiclient.builder(context).addapi(nearby.messages_api, messagesoptionsbuilder); test.addconnectioncallbacks(new com.google.android.gms.common.api.googleapiclient.connectioncallbacks({ onconnected: function (connectionhint) { var messagelistener = messagelistener.extend({ onfound: function (message) { console.log(found message :) "); }, onlost: function (message) { console.log("lost message :( "); } }); var mmessagelistener = new messagelistener(); }, onconnectionsuspended: function () { } }));
and incase messagelistener interface remove .extend
var messagesoptionsbuilder = new com.google.android.gms.nearby.messages.messagesoptions.builder().setpermissions(nearbypermissions.ble).build(); var test = new googleapiclient.builder(context).addapi(nearby.messages_api, messagesoptionsbuilder); test.addconnectioncallbacks(new com.google.android.gms.common.api.googleapiclient.connectioncallbacks({ onconnected: function (connectionhint) { new messagelistener({ onfound: function (message) { console.log(found message :) "); }, onlost: function (message) { console.log("lost message :( "); } }); }, onconnectionsuspended: function () { } }));
Comments
Post a Comment