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

Update to 4.0.1 and got error: Cannot read property 'initialize' of undefined #482

Closed
Dashue opened this issue Sep 9, 2017 · 4 comments
Closed
Milestone

Comments

@Dashue
Copy link

Dashue commented Sep 9, 2017

An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.readersguide.android/com.tns.NativeScriptActivity}: com.tns.NativeScriptException:
Calling js method onCreate failed

TypeError: Cannot read property 'initialize' of undefined
File: "file:///data/data/com.readersguide.android/files/app/tns_modules/nativescript-plugin-firebase/firebase.js, line: 290, column: 44

StackTrace:
Frame: function:'runInit', file:'file:///data/data/com.readersguide.android/files/app/tns_modules/nativescript-plugin-firebase/firebase.js', line: 290, column: 45
Frame: function:'Observable.notify', file:'file:///data/data/com.readersguide.android/files/app/tns_modules/tns-core-modules/data/observable/observable.js', line: 103, column: 23
Frame: function:'ActivityCallbacksImplementation.onCreate', file:'file:///data/data/com.readersguide.android/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 675, column: 36
Frame: function:'NativeScriptActivity.onCreate', file:'file:///data/data/com.readersguide.android/files/app/tns_modules/tns-core-modules/ui/frame/activity.js', line: 20, column: 25

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: com.tns.NativeScriptException:
Calling js method onCreate failed

TypeError: Cannot read property 'initialize' of undefined
File: "file:///data/data/com.readersguide.android/files/app/tns_modules/nativescript-plugin-firebase/firebase.js, line: 290, column: 44

StackTrace:
Frame: function:'runInit', file:'file:///data/data/com.readersguide.android/files/app/tns_modules/nativescript-plugin-firebase/firebase.js', line: 290, column: 45
Frame: function:'Observable.notify', file:'file:///data/data/com.readersguide.android/files/app/tns_modules/tns-core-modules/data/observable/observable.js', line: 103, column: 23
Frame: function:'ActivityCallbacksImplementation.onCreate', file:'file:///data/data/com.readersguide.android/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 675, column: 36
Frame: function:'NativeScriptActivity.onCreate', file:'file:///data/data/com.readersguide.android/files/app/tns_modules/tns-core-modules/ui/frame/activity.js', line: 20, column: 25

at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
at com.tns.Runtime.callJSMethod(Runtime.java:912)
at com.tns.Runtime.callJSMethod(Runtime.java:896)
at com.tns.Runtime.callJSMethod(Runtime.java:888)
at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:13)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
... 9 more
@EddyVerbruggen
Copy link
Owner

Interesting.. do you have AdMob enabled? If not then something else is adding a class in the com.google.android.gms.ads package and we need to expand this check to:

if (typeof(com.google.android.gms.ads) !== "undefined" && typeof(com.google.android.gms.ads.MobileAds) !== "undefined") {

You can try that in your own project to see if it fixes the issue. Just tweak the file in node_modules/nativescript-plugin-firebase/firebase.android.js, rm -rf platforms/android and run the project again.

@Dashue
Copy link
Author

Dashue commented Sep 9, 2017

I don't have AdMob enabled (haven't gotten around to it).

Downgrading back to 3.12.0 makes it work again for now

I'll try that fix now and let you know.

@EddyVerbruggen
Copy link
Owner

OK - if you like you can upgrade to 4.1.1 which should fix the problem (I applied that code suggestion.. didn't test it but I can't see a reason why it wouldn't work).

@Dashue
Copy link
Author

Dashue commented Sep 9, 2017

Yup that made it work!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants