Nativescript-plugin-firebase: Tried to serialize an unsupported type: javaObj.getClass().getName()

Created on 18 Jul 2018  Â·  13Comments  Â·  Source: EddyVerbruggen/nativescript-plugin-firebase

_From @RaphaelJenni on June 25, 2018 11:21_

Did you verify this is a real problem by searching the NativeScript Forum and the other open issues in this repo?

Haven't found anything.

Which platform(s) does your issue occur on?

Only tested on Android

Please provide the following version numbers that your issue occurs with:

  • CLI: 4.1.1
  • Cross-platform modules: 4.1.0
  • Runtime(s): iOS - 4.1.1, Android - 4.1.3
  • Plugin(s):
{
  "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",
    "email-validator": "1.1.1",
    "lodash": "4.17.5",
    "moment": "2.22.1",
    "nativescript-algolia": "0.0.4",
    "nativescript-angular": "^6.0.0",
    "nativescript-carousel": "3.1.1",
    "nativescript-gif": "4.0.0",
    "nativescript-iqkeyboardmanager": "1.3.0",
    "nativescript-material-icons": "1.0.3",
    "nativescript-ngx-fonticon": "4.1.0",
    "nativescript-plugin-firebase": "6.3.0",
    "nativescript-ripple": "2.0.0",
    "nativescript-secure-storage": "2.2.2",
    "nativescript-theme-core": "1.0.4",
    "nativescript-timedatepicker": "1.2.1",
    "nativescript-ui-sidedrawer": "4.1.0",
    "nativescript-unit-test-runner": "^0.3.4",
    "object-assign": "4.1.1",
    "reflect-metadata": "0.1.8",
    "rxjs": "~6.0.0 || >=6.1.0",
    "rxjs-compat": "^6.2.1",
    "tns-core-modules": "4.1.0",
    "tslib": "1.7.1",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/core": "~0.7.0-beta.1",
    "@angular/compiler-cli": "~6.0.0",
    "@ngtools/webpack": "~6.1.0-beta.1",
    "@types/jasmine": "^2.8.6",
    "@types/jsonfile": "4.0.1",
    "@types/request-promise": "4.1.41",
    "babel-traverse": "6.26.0",
    "babel-types": "6.26.0",
    "babylon": "6.18.0",
    "clean-webpack-plugin": "~0.1.19",
    "codelyzer": "4.3.0",
    "copy-webpack-plugin": "~4.5.1",
    "css-loader": "~0.28.11",
    "enhanced-resolve": "3.4.1",
    "extract-text-webpack-plugin": "~3.0.2",
    "fs-extra": "5.0.0",
    "git-describe": "4.0.2",
    "husky": "0.14.3",
    "jasmine": "^3.1.0",
    "jasmine-core": "^3.1.0",
    "jsonfile": "4.0.0",
    "karma": "^2.0.2",
    "karma-jasmine": "^1.1.0",
    "karma-junit-reporter": "1.1.0",
    "karma-nativescript-launcher": "^0.4.0",
    "karma-typescript-preprocessor": "0.3.1",
    "lazy": "1.0.11",
    "lint-staged": "6.1.1",
    "nativescript": "4.1.1",
    "nativescript-css-loader": "0.26.1",
    "nativescript-dev-sass": "1.6.0",
    "nativescript-dev-typescript": "0.7.1",
    "nativescript-dev-webpack": "^0.13.0",
    "nativescript-worker-loader": "~0.9.0",
    "node-sass": "4.8.3",
    "optimist": "0.6.1",
    "prettier": "1.12.1",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.3.0",
    "sass-loader": "~7.0.1",
    "sharp": "0.16.0",
    "tns-platform-declarations": "4.0.0",
    "tsc-watch": "^1.0.22",
    "tslint": "5.8.0",
    "tslint-config-prettier": "1.12.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",
    "xcode": "1.0.0"
  }
}

Please tell us how to recreate the issue in as much detail as possible.

Sign in with google and this error apperars.

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

JS: PLEASE REPORT THIS AT https://github.com/NativeScript/NativeScript/issues: Tried to serialize an unsupported type: javaObj.getClass().getName(), error: Error: java.lang.IllegalStateException: This container does not support retaining Map.Entry objects
JS:     android.support.v4.util.MapCollections$MapIterator.equals(MapCollections.java:136)
JS:     com.tns.NativeScriptWeakHashMap.get(NativeScriptWeakHashMap.java:452)
JS:     com.tns.Runtime.getJavaObjectID(Runtime.java:923)
JS:     com.tns.Runtime.getOrCreateJavaObjectID(Runtime.java:931)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:970)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:954)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:946)
JS:     com.tns.gen.com.google.android.gms.tasks.OnCompleteListener.onComplete(OnCompleteListener.java:16)
JS:     com.google.android.gms.tasks.zzj.run(Unknown Source:23)
JS:     ...

_Copied from original issue: NativeScript/NativeScript#5990_

Android Authentication bug

Most helpful comment

Turned out it was one of the java.lang.Integer types in the user profile that caused the issues. Fix is part of 6.4.1.

All 13 comments

@RaphaelJenni please post as much as possible information about how to reproduce the issue including any related codebase and what steps are taken. A sample project or Playground demonstrating the issue would help as well.

_From @freddiandrew on June 29, 2018 14:6_

i also face the same issue when create login using google login (firebase), use the following plugin firebase https://github.com/EddyVerbruggen/nativescript-plugin-firebase,

firebase.login({
            type : firebase.LoginType.GOOGLE
        }).then((user) => { })

@freddiandrew both the plugin demo and this POC project are using the Firebase login method and I am not able to reproduce the issue.

Is the issue happening on a specific device/ API level? Is there any specific code that can help us reproduce the issue?

_From @axd on July 9, 2018 0:59_

It's happening to me with Faebook login using Firebase, I'm trying to play around with this script: https://github.com/anchetaWern/fitapp-push

JS: firebase.init done
JS: PLEASE REPORT THIS AT https://github.com/NativeScript/NativeScript/issues: Tried to serialize an unsupported type: javaObj.getClass().getName(), error: TypeError: javaObj.entrySet is not a function
JS: PLEASE REPORT THIS AT https://github.com/NativeScript/NativeScript/issues: Tried to serialize an unsupported type: javaObj.getClass().getName(), error: TypeError: javaObj.entrySet is not a function
JS: Trying FB
System.err: com.tns.NativeScriptException: 
System.err: Calling js method run failed
System.err: 
System.err: SyntaxError: Unexpected token u in JSON at position 0
System.err: File: "<unknown>, line: 1, column: 0
System.err: 
System.err: StackTrace: 
System.err:     Frame: function:'', file:'file:///data/data/com.debug.tracker/files/app/main-view-model.js', line: 90, column: 37
System.err:     Frame: function:'invoke', file:'file:///data/data/com.debug.tracker/files/app/tns_modules/tns-core-modules/timer/timer.js', line: 19, column: 48
System.err:     Frame: function:'run', file:'file:///data/data/com.debug.tracker/files/app/tns_modules/tns-core-modules/timer/timer.js', line: 23, column: 13
System.err: 
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:970)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:954)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:946)
System.err:     at com.tns.gen.java.lang.Runnable.run(Runnable.java:15)
System.err:     at android.os.Handler.handleCallback(Handler.java:751)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
System.err:     at android.os.Looper.loop(Looper.java:154)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6119)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

_From @ponnex on July 13, 2018 3:52_

Same here happening on Facebook login using nativescript-plugin-firebase. This only happens when using webpack or --build

JS: PLEASE REPORT THIS AT https://github.com/NativeScript/NativeScript/issues: Tried to serialize an unsupported type: javaObj.getClass().getName(), error: Error: java.lang.IllegalStateException: Thiscontainer does not support retaining Map.Entry objects
JS: android.support.v4.util.MapCollections$MapIterator.equals(MapCollections.java:136)
JS: com.tns.NativeScriptWeakHashMap.get(NativeScriptWeakHashMap.java:452)
JS: com.tns.Runtime.getJavaObjectID(Runtime.java:923)
JS: com.tns.Runtime.getOrCreateJavaObjectID(Runtime.java:931)
JS: com.tns.Runtime.callJSMethodNative(Native Method)
JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
JS: com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
JS: com.tns.Runtime.callJSMethod(Runtime.java:970)
JS: com.tns.Runtime.callJSMethod(Runtime.java:954)
JS: com.tns.Runtime.callJSMethod(Runtime.java:946)
JS: com.tns.gen.com.google.android.gms.tasks.OnCompleteListener.onComplete(OnCompleteListener.java:16)
JS: com.google.android.gms.tasks.zzj.run(Unknown Source)
JS: and...

_From @keerl on July 17, 2018 15:56_

I have the same issue when using Google authentication with the Firebase plugin as @freddiandrew said above. The Google login actually works fine, but it just throws this error every time.

@RaphaelJenni @freddiandrew @ponnex @keerl I was able to reproduce the issue when using nativescript-plugin-firebase. The error is non-blocking and appeared in the Android logcat after successful Facebook login.

Note: the issue was reproduced with CLI builds as well (not only with Webpack)

The application used to test the issue can be found here.

Steps to reproduce:

  • open the application and monitor the Android logcat
  • log in using the Facebook option

Logcat

07-18 06:12:54.943 23581-23581/org.nativescript.curiosity I/JS: PLEASE REPORT THIS AT https://github.com/NativeScript/NativeScript/issues: Tried to serialize an unsupported type: javaObj.getClass().getName(), error: Error: java.lang.IllegalStateException: This container does not support retaining Map.Entry objects
        android.support.v4.util.MapCollections$MapIterator.equals(MapCollections.java:136)
        com.tns.NativeScriptWeakHashMap.get(NativeScriptWeakHashMap.java:452)
        com.tns.Runtime.getJavaObjectID(Runtime.java:923)
        com.tns.Runtime.getOrCreateJavaObjectID(Runtime.java:931)
        com.tns.Runtime.callJSMethodNative(Native Method)
        com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
        com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
        com.tns.Runtime.callJSMethod(Runtime.java:970)
        com.tns.Runtime.callJSMethod(Runtime.java:954)
        com.tns.Runtime.callJSMethod(Runtime.java:946)
        com.tns.gen.com.google.android.gms.tasks.OnCompleteListener.onComplete(OnCompleteListener.java:16)
        com.google.android.gms.tasks.zzj.run(Unknown Source)
        and...
07-18 06:12:54.944 23581-23581/org.nativescript.curiosity I/JS: PLEASE REPORT THIS AT https://github.com/NativeScript/NativeScript/issues: Tried to serialize an unsupported type: javaObj.getClass().getName(), error: TypeError: javaObj.entrySet is not a function
07-18 06:12:54.949 23581-23581/org.nativescript.curiosity I/JS: PLEASE REPORT THIS AT https://github.com/NativeScript/NativeScript/issues: Tried to serialize an unsupported type: javaObj.getClass().getName(), error: Error: java.lang.IllegalStateException: This container does not support retaining Map.Entry objects
        android.support.v4.util.MapCollections$MapIterator.equals(MapCollections.java:136)
        com.tns.NativeScriptWeakHashMap.get(NativeScriptWeakHashMap.java:452)
        com.tns.Runtime.getJavaObjectID(Runtime.java:923)
        com.tns.Runtime.getOrCreateJavaObjectID(Runtime.java:931)
        com.tns.Runtime.callJSMethodNative(Native Method)
        com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
        com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
        com.tns.Runtime.callJSMethod(Runtime.java:970)
        com.tns.Runtime.callJSMethod(Runtime.java:954)
        com.tns.Runtime.callJSMethod(Runtime.java:946)
        com.tns.gen.com.google.android.gms.tasks.OnCompleteListener.onComplete(OnCompleteListener.java:16)
        com.google.android.gms.tasks.zzj.run(Unknown Source)
        and...

Thanks for forwarding those issues, @NickIliev! That log message should have read "PLEASE REPORT THIS AT https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues ..." in the first place, sorry for the noise.

Note that indeed this is a warning, not an error. The login works fine it's just that some part of the user profile can't be serialized from Java to JS and gets ignored in the result (but this log appears so it's not swallowed silently, so I can try and serialize it correctly). I'll look into it..

Turned out it was one of the java.lang.Integer types in the user profile that caused the issues. Fix is part of 6.4.1.

Hi @EddyVerbruggen
Still getting this warning using 6.4.1

JS: The return payload of login with google: {"uid":"oUQRABl0U3QD0JqjmdbOX3qoqL42","name":"Katy M","email":"[email protected]","emailVerified":true,"providers":[{"id":"firebase"},{"id":"google.com"},{"id":"phone"}],"anonymous":false,"isAnonymous":false,"phoneNumber":"+112345678","profileImageURL":"https://lh4.googleusercontent.com/-9teinf3pgck/AAAAAAAAAAI/AAAAAAAAAAA/AAnnY7qq-ykw-wbXQyTb-6hTpY39ArYZNg/s96-c/photo.jpg","metadata":{"creationTimestamp":"2018-08-06T11:05:37.000Z","lastSignInTimestamp":"2018-08-06T12:02:03.000Z"},"additionalUserInfo":{"providerId":"google.com","username":null,"isNewUser":false,"profile":{"given_name":"Katy","locale":"en-GB","family_name":"M","picture":"https://lh4.googleusercontent.com/-9teinf3pgck/AQyTb-6hTpY39ArYZNg/s96-c/photo.jpg","aud":"443002779827-86iflmfe8r4dghjgebea0im36jp6mnsj.apps.googleusercontent.com","azp":"443002779827-1is0s60srq51th2c5v8ahetlivb8qjin.apps.googleusercontent.com","exp":1533559988,"iat":1533556388,"iss":"https:/...
JS: PLEASE REPORT THIS AT https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues: Tried to serialize an unsupported type: android.support.v4.util.ArrayMap, error: Error: java.lang.IllegalStateException: This container does not support retaining Map.Entry objects
JS:     android.support.v4.util.MapCollections$MapIterator.equals(MapCollections.java:133)
JS:     com.tns.NativeScriptWeakHashMap.get(NativeScriptWeakHashMap.java:452)
JS:     com.tns.Runtime.getJavaObjectID(Runtime.java:923)
JS:     com.tns.Runtime.getOrCreateJavaObjectID(Runtime.java:931)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:970)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:954)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:946)
JS:     com.tns.gen.com.google.android.gms.tasks.OnCompleteListener.onComplete(OnCompleteListener.java:16)
JS:     com.google.android.gms.tasks.zzj.run(U...

Ha, that’s actually a new type of error, with the updated ‘report at’ link. Thx for letting me know!

@anuragd7 follow-up in #834.

Was this page helpful?
0 / 5 - 0 ratings