Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Class not found error #1410

Closed
yiwong2001 opened this issue Nov 24, 2016 · 14 comments
Closed

Class not found error #1410

yiwong2001 opened this issue Nov 24, 2016 · 14 comments

Comments

@yiwong2001
Copy link

yiwong2001 commented Nov 24, 2016

Expected Behaviour

Receive reg id from google server

Actual Behaviour

Got 'class not found' error from on('error')... handler,

Platform and Version (eg. Android 5.0 or iOS 9.2.1)
Android6.0 api23

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

virtual device & Mate7 huawei

Cordova CLI version and cordova platform version
cordova 6.4.0

Plugin version
1.8.2

Hi, I am trying this plugin in a simple cordova-android app. I have installed plugin successfully and compiled project with no problem. But when I run it on virtual device OR my Huawei mate7. Both device got Class not found from push.on('error')

11-25 01:09:01.738 15455-15455/this.is.my.package I/chromium: [INFO:CONSOLE(80)] "Class not found", source: file:///android_asset/www/js/index.js (80)

onDeviceReady: function() {
        app.receivedEvent('deviceready');
        var push = PushNotification.init({
                  android: {
                      senderID: "this_is_my_senderid"
                  }
              });

push.on('error', function(e) {
console.log(e.message);
console.log(e);
});
              push.on('registration', function(data) {
                  console.log(data.registrationId);
              });

              push.on('notification', function(data) {
                  console.log(data.message);
                  console.log(data.title);
                  console.log(data.count);
                  console.log(data.sound);
                  console.log(data.image);
                  console.log(data.additionalData);
              });

Can you give me some guidance? thanks!

@macdonst
Copy link
Member

Sorry to be a jerk but I'm now closing issues that don't follow the issue submission guidelines. This plugin takes a lot of work to maintain and I can't afford the time required to solicit the required info from everyone.

I'm closing this issue but please feel free to re-open the issue if you provide the requested details from the new issue submission guidelines.

https://github.com/phonegap/phonegap-plugin-push/blob/master/.github/ISSUE_TEMPLATE.md

@yiwong2001
Copy link
Author

yiwong2001 commented Nov 24, 2016

sorry macdonst, I was editing that issue with more details when you closed it. :( can you please reopen it?

@macdonst macdonst reopened this Nov 24, 2016
@fredgalvao
Copy link
Collaborator

Can you check and post here what exactly is on www/js/index.js:80?

@macdonst
Copy link
Member

@yiwong2001 it seems like the Android code that the plugin installs did not get loaded correctly. Can you check to see that there are actually classes in platforms/android/src/com/adobe/phonegap/push? If they are missing it was an issue with installing the plugin. If they are there run adb logcat | grep PushPlugin and start the app.

@yiwong2001
Copy link
Author

image

@macdonst I can see all classes in folder you mentioned. But I can not see any error in log related to "PushPlugin"

@fredgalvao line80 is console.log(e.message) in push.on("err");

@fredgalvao
Copy link
Collaborator

If the exception came from your error event, then the native code for the plugin exists and kinda worked. Now we need to see the whole log from logcat to see what went wrong in the native side.

@macdonst
Copy link
Member

@yiwong2001 yeah, run this on a real device, not the emulator and let's see what adb logcat complains about.

@yiwong2001
Copy link
Author

hi @macdonst and @fredgalvao,

I noticed some errors in full log

11-24 23:55:15.020 11101-11101/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.pubble.mod, PID: 11101
java.lang.RuntimeException: Unable to start activity ComponentInfo{io.pubble.mod/io.pubble.mod.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CordovaPlugin.privateInitialize(java.lang.String, org.apache.cordova.CordovaInterface, org.apache.cordova.CordovaWebView, org.apache.cordova.CordovaPreferences)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CordovaPlugin.privateInitialize(java.lang.String, org.apache.cordova.CordovaInterface, org.apache.cordova.CordovaWebView, org.apache.cordova.CordovaPreferences)' on a null object reference
at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:171)
at org.apache.cordova.PluginManager.startupPlugins(PluginManager.java:97)
at org.apache.cordova.PluginManager.init(PluginManager.java:86)
at org.apache.cordova.CordovaWebViewImpl.init(CordovaWebViewImpl.java:115)
at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:149)
at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:224)
at io.pubble.mod.MainActivity.onCreate(MainActivity.java:32)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
11-24 23:55:15.626 2029-2173/com.android.launcher3 E/EGL_emulation: tid 2173: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH)
11-24 23:55:31.963 11203-11203/? E/AndroidRuntime: FATAL EXCEPTION: main

===================

===================

11-25 01:10:47.586 1998-1998/com.google.android.gms.persistent D/Error: ERR: TOTAL BYTES WRITTEN: 35884
11-25 01:10:47.586 1998-1998/com.google.android.gms.persistent D/StrictMode: Wrote violation #2 of 5: 35928 bytes
11-25 01:10:47.586 1998-1998/com.google.android.gms.persistent D/Error: ERR: exClass=android.os.StrictMode$StrictModeDiskWriteViolation
11-25 01:10:47.586 1998-1998/com.google.android.gms.persistent D/Error: ERR: exMsg=policy=6815751 violation=1
11-25 01:10:47.586 1998-1998/com.google.android.gms.persistent D/Error: ERR: file=StrictMode.java
11-25 01:10:47.586 1998-1998/com.google.android.gms.persistent D/Error: ERR: class=android.os.StrictMode$AndroidBlockGuardPolicy
11-25 01:10:47.586 1998-1998/com.google.android.gms.persistent D/Error: ERR: method=onWriteToDisk line=1223
11-25 01:10:47.587 1998-1998/com.google.android.gms.persistent D/Error: ERR: stack=android.os.StrictMode$StrictModeDiskWriteViolation: policy=6815751 violation=1
at android.os.StrictMode$AndroidBlockGuardPolicy.onWriteToDisk(StrictMode.java:1223)
at libcore.io.BlockGuardOs.remove(BlockGuardOs.java:254)
at java.io.File.delete(File.java:311)
at android.database.sqlite.SQLiteDatabase.deleteDatabase(SQLiteDatabase.java:734)
at android.app.ContextImpl.deleteDatabase(ContextImpl.java:580)
at android.content.ContextWrapper.deleteDatabase(ContextWrapper.java:274)
at android.content.ContextWrapper.deleteDatabase(ContextWrapper.java:274)
at android.content.ContextWrapper.deleteDatabase(ContextWrapper.java:274)
at aicc.a(:com.google.android.gms:1570)
at com.google.android.location.reporting.service.DispatchingChimeraService.onCreate(:com.google.android.gms:574)
at com.google.android.chimera.container.ServiceProxy.onCreate(:com.google.android.gms:165)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2877)
at android.app.ActivityThread.-wrap4(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
# via Binder call with stack:
android.os.StrictMode$LogStackTrace
at android.os.StrictMode.readAndHandleBinderCallViolations(StrictMode.java:1911)
at android.os.Parcel.readExceptionCode(Parcel.java:1580)
at android.os.Parcel.readException(Parcel.java:1549)
at kdb.isGoogleSigned(:com.google.android.gms:181)
at ixq.b(:com.google.android.gms:477)
at jmb.b(:com.google.android.gms:253)
at jmb.a(:com.google.android.gms:157)
at pyl.b(:com.google.android.gms:127)
at pyl.(:com.google.android.gms:3108)
at pyl.(:com.google.android.gms:79)
at pzn.a(:com.google.android.gms:476)
at pzn.a(:com.google.android.gms:381)
at pzo.handleMessage(:com.google.android.gms:3045)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
# via Binder call with stack:
android.os.StrictMode$LogStackTrace
at android.os.StrictMode.readAndHandleBinderCallViolations(StrictMode.java:1911)
at android.os.Parcel.readExceptionCode(Parcel.java:1580)
at android.os.Parcel.readException(Parcel.java:1549)
at kcv.a(:com.google.android.gms:119)
at kbx.a(:com.google.android.gms:66)
at nfh.a(:com.google.android.gms:187)
at kaq.a(:com.google.android.gms:596)
at kcx.onTransact(:com.google.android.gms:824)
at android.os.Binder.execTransact(Binder.java:453)
# via Binder call with stack:
android.os.StrictMode$LogStackTrace
at android.os.StrictMode.readAndHandleBinderCallViolations(StrictMode.java:1911)
at android.os.Parcel.readExceptionCode(Parcel.java:1580)
at android.os.Parcel.readException(Parcel.java:1549)
at kcy.a(:com.google.android.gms:1949)
at kaw.a(:com.google.android.gms:1305)
at kbf.a(:com.google.android.gms:406)
at kbh.a(:com.google.android.gms:731)
at kax.a(:com.google.android.gms:1835)
at kba.handleMessage(:com.google.android.gms:4343)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
# via Binder call with stack:
android.os.StrictMode$LogStackTrace
at android.os.StrictMode.readAndHandleBinderCallViolations(StrictMode.java:1911)
at android.os.Par

@yiwong2001
Copy link
Author

Seems push plugin is not registered correctly

11-25 02:13:34.852 17181-17181/io.pubble.mod D/PluginManager: init()
11-25 02:13:35.447 17181-17221/io.pubble.mod D/PluginManager: exec() call to unknown plugin: PushNotification

Where should I check to register it?

@macdonst
Copy link
Member

@yiwong2001 I think you should do a:

cordova plugin rm phonegap-plugin-push
cordova plugin add phonegap-plugin-push --variable SENDER_ID=XXXXXXX

@yiwong2001
Copy link
Author

@macdonst, got little bit progress, but still need ur help :)

I reinstalled plugin, and it really helped.

now I got timeout in log.

E/PushPlugin(20077): execute: Got JSON Exception TIMEOUT

According to documentation, it says, I need to update play service version. Does it mean I need to update google play service version on my virtual device?

@yiwong2001
Copy link
Author

yiwong2001 commented Nov 24, 2016

I tried it on huawei mate7. It has no timeout issue. I guess google service version on virtual device is too old.

Now I got following error:

11-25 03:25:46.204 10389-10458/io.pubble.mod E/PushPlugin: execute: Got JSON Exception INVALID_SENDER
11-25 03:25:46.227 10389-10389/io.pubble.mod I/chromium: [INFO:CONSOLE(72)] "INVALID_SENDER", source: file:///android_asset/www/js/index.js (72)

But I am sure I set correct sender_id in js

var push = PushNotification.init({
android: {
senderID: "my_correct_senderid"
}
});

@yiwong2001
Copy link
Author

sorry. It turned out I still used wrong senderID. thanks for your help @macdonst and fredgalvao.

@lock
Copy link

lock bot commented Jun 4, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants