rhanb / nativescript-bottombar

Fancy bottom bar for NativeScript :smile: :beers:
Apache License 2.0
65 stars 24 forks source link

[Nativescript 6.0 upgrade] Could not load view for: nativebottombar. Cannot read property 'widget' of undefined #87

Open fabioaraujo121 opened 5 years ago

fabioaraujo121 commented 5 years ago

Nativescript-vue

Which platform(s) does your issue occur on?

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

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

I've upgraded from 5.0.0 to 6.0.0; This crashed my app. I can't build. I'm receiving this error when I run tns run android --bundle:

System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to start activity ComponentInfo{mpb.mpbpay/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: TypeError: Could not load view for: nativebottombar. TypeError: Cannot read property 'widget' of undefined
System.err: 
System.err: StackTrace:
System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{mpb.mpbpay/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: TypeError: Could not load view for: nativebottombar. TypeError: Cannot read property 'widget' of undefined
System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2916)
System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3051)
System.err:     at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
System.err:     at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
System.err:     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1811)
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:6694)
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: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: TypeError: Could not load view for: nativebottombar. TypeError: Cannot read property 'widget' of undefined
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1109)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1089)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1081)
System.err:     at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:19)
System.err:     at android.app.Activity.performCreate(Activity.java:7136)
System.err:     at android.app.Activity.performCreate(Activity.java:7127)
System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
rhanb commented 5 years ago

Hello @fabioaraujo121 ,

Thank you for reporting this issue.

This plugin hasn't been tested against v6 yet. After testing it with v6 I'll be able to come back to you to fix your issue.

Regards

amizz commented 5 years ago

Are there any updates regarding this problem? If anyone found a solution would you mind sharing it?

amizz commented 5 years ago

Ok found the solution.

Use android material library dependency

dependencies {
  implementation "com.google.android.material:material:1.1.0-alpha07"
}

Navigate to nativescript-bottombar/src/bottombar/android/bottombar.js and change to this from android.support

var BottomNavigationView = com.google.android.material.bottomnavigation.BottomNavigationView;

This is a quick fix. Hope the author will fix it later.

yschiele commented 5 years ago

Thanks man @amizz! You saved my day