EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 444 forks source link

App crashes when receiving a push notification if using the Firebase and Mixpanel plugins #1182

Closed indiggojorge closed 5 years ago

indiggojorge commented 5 years ago

My app uses Mixpanel to send usage tracking data to Mixpanel. We are using Firebase to receive push notifications. The issue is that when on an Android device, we get the following exception when a notification is pushed to the device.

System.err: java.lang.RuntimeException: Unable to instantiate receiver com.mixpanel.android.mpmetrics.GCMReceiver: java.lang.ClassNotFoundException: Didn't find class "com.mixpanel.android.mpmetrics.GCMReceiver" on path: DexPathList[[zip file "/data/app/com.indiggolead.indiggoapp-AXPfOUuLxa4nxVq_Q_5jTA==/base.apk"],nativeLibraryDirectories=[/data/app/com.indiggolead.indiggoapp-AXPfOUuLxa4nxVq_Q_5jTA==/lib/arm, /data/app/com.indiggolead.indiggoapp-AXPfOUuLxa4nxVq_Q_5jTA==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]] System.err: at android.app.ActivityThread.handleReceiver(ActivityThread.java:3403) System.err: at android.app.ActivityThread.access$1200(ActivityThread.java:200) System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1667) System.err: at android.os.Handler.dispatchMessage(Handler.java:106) System.err: at android.os.Looper.loop(Looper.java:193) System.err: at android.app.ActivityThread.main(ActivityThread.java:6718) System.err: at java.lang.reflect.Method.invoke(Native Method) System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mixpanel.android.mpmetrics.GCMReceiver" on path: DexPathList[[zip file "/data/app/com.indiggolead.indiggoapp-AXPfOUuLxa4nxVq_Q_5jTA==/base.apk"],nativeLibraryDirectories=[/data/app/com.indiggolead.indiggoapp-AXPfOUuLxa4nxVq_Q_5jTA==/lib/arm, /data/app/com.indiggolead.indiggoapp-AXPfOUuLxa4nxVq_Q_5jTA==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]] System.err: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134) System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:379) System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:312) System.err: at android.app.AppComponentFactory.instantiateReceiver(AppComponentFactory.java:84) System.err: at android.support.v4.app.CoreComponentFactory.instantiateReceiver(CoreComponentFactory.java:56) System.err: at android.app.ActivityThread.handleReceiver(ActivityThread.java:3396) System.err: ... 8 more If we remove mixpanel from the app, we receive push notifications just fine. The issue is only on Android and not on iOS devices.

So there seems to be a conflict between the Firebase and Mixpanel plugins. How can we work around this?

martinstofko219 commented 5 years ago

After further investigation, the issue was in the nativescript-mixpanel plugin. It is using an outdated reference to a service that no longer works. I created a PR for the mixpanel plugin fixing this issue.

https://github.com/AntonioCuevaUrraco/nativescript-mixpanel/pull/8

EddyVerbruggen commented 5 years ago

Awesome, thanks for letting us know! 👍

moeidsaleem commented 5 years ago

We are still facing the same issue while generating push notification from firebase console. The app is crashing.

{
  "description": "DigitalOB",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "README.md",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "com.mashreq.dobuat",
    "tns-ios": {
      "version": "4.2.0"
    },
    "tns-android": {
      "version": "4.2.0"
    }
  },
  "dependencies": {
    "@angular/animations": "~6.0.0",
    "@angular/common": "~6.0.0",
    "@angular/compiler": "~6.0.0",
    "@angular/core": "~6.0.0",
    "@angular/forms": "~6.0.0",
    "@angular/http": "~6.0.0",
    "@angular/platform-browser": "~6.0.0",
    "@angular/platform-browser-dynamic": "~6.0.0",
    "@angular/router": "~6.0.0",
    "@types/crypto-js": "^3.1.39",
    "@types/lodash": "^4.14.107",
    "crypto-js": "^3.1.9-1",
    "kinvey-nativescript-sdk": "^3.10.0",
    "lodash": "^4.17.5",
    "nativescript-accelerometer": "^2.0.1",
    "nativescript-angular": "^6.0.0",
    "nativescript-angular-cli": "^0.1.9",
    "nativescript-appversion": "^1.4.1",
    "nativescript-background-http": "^3.3.0",
    "nativescript-camera": "^4.0.0",
    "nativescript-cardreader": "file:../Plugins/nativescript-cardreader-1.0.0.tgz",
    "nativescript-checkbox": "^3.0.3",
    "nativescript-drop-down": "^3.2.5",
    "nativescript-filter-select": "^1.2.9",
    "nativescript-filterable-listpicker": "^2.0.2",
    "nativescript-fresco": "^3.0.6",
    "nativescript-geolocation": "^4.3.1",
    "nativescript-gradient": "^2.0.1",
    "nativescript-intl": "^3.0.0",
    "nativescript-iqkeyboardmanager": "^1.2.0",
    "nativescript-lan-scan": "^0.3.1",
    "nativescript-loading-indicator": "^2.4.0",
    "nativescript-localstorage": "^1.1.5",
    "nativescript-mixpanel": "^2.0.1",
    "nativescript-modal-datetimepicker": "^1.1.3",
    "nativescript-photoviewer": "^1.4.0",
    "nativescript-plugin-firebase": "^7.1.6",
    "nativescript-pulltorefresh": "^2.1.1",
    "nativescript-social-share": "^1.5.0",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-toast": "^1.4.6",
    "nativescript-ui-autocomplete": "^3.11.0",
    "nativescript-ui-calendar": "^3.5.0",
    "nativescript-ui-chart": "^3.5.0",
    "nativescript-ui-dataform": "^3.5.0",
    "nativescript-ui-gauge": "^3.5.0",
    "nativescript-ui-sidedrawer": "^3.5.1",
    "reflect-metadata": "~0.1.12",
    "rxjs": "^6.2.2",
    "rxjs-compat": "^6.2.2",
    "tns-core-modules": "^4.2.1",
    "tns-ng": "^1.1.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/core": "~0.6.3",
    "@angular/compiler-cli": "~6.0.0",
    "@ngtools/webpack": "~6.0.3",
    "babel-traverse": "6.25.0",
    "babel-types": "6.25.0",
    "babylon": "6.17.4",
    "clean-webpack-plugin": "~0.1.19",
    "copy-webpack-plugin": "~4.5.1",
    "css-loader": "~0.28.11",
    "extract-text-webpack-plugin": "~3.0.2",
    "lazy": "1.0.11",
    "nativescript-dev-typescript": "~0.6.0",
    "nativescript-dev-webpack": "^0.12.0",
    "nativescript-worker-loader": "~0.9.0",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.3.0",
    "typescript": "~2.7.2",
    "uglifyjs-webpack-plugin": "~1.2.5",
    "webpack": "~4.6.0",
    "webpack-bundle-analyzer": "~2.13.0",
    "webpack-cli": "~2.1.3",
    "webpack-sources": "~1.1.0"
  }
}

and following is the error we are facing

Screen Shot 2019-05-06 at 12 44 06 PM

And following is app.gradle file

// Add your native dependencies here:

// Uncomment to add recyclerview-v7 dependency
dependencies {
     compile "io.reactivex:rxjava:1.2.7"
     compile "io.reactivex:rxandroid:1.2.1"
     implementation 'com.google.gms:google-services:4.0.1'
}

android {  
    project.ext {
    googlePlayServicesVersion = "16.0.+"
  }
  lintOptions {
    checkReleaseBuilds false
    // Or, if you prefer, you can continue to check for errors in release builds,
    // but continue the build even when errors are found:
    abortOnError false
  }
  defaultConfig {  
    generatedDensities = []
    applicationId = "com.mashreq.dobuat" 
    multiDexEnabled true 
  }  
  aaptOptions {  
    additionalParameters "--no-version-vectors"  
  }
  dexOptions {
    javaMaxHeapSize "4g"
  }  
}