nativescript-community / ui-material-components

Monorepo that contains all of the NativeScript Material Design plugins.
https://nativescript-community.github.io/ui-material-components/
Apache License 2.0
219 stars 80 forks source link

ui-material-bottom-navigation not working on Android #362

Closed update-switzerland closed 2 years ago

update-switzerland commented 2 years ago

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.

When I use the bottom-navigation material, I get an error saying:

Module '@nativescript-community/ui-material-bottom-navigation' not found for element '@nativescript-community/ui-material-bottom-navigation:MDTabStrip'

When I remove the MD from the TabStrip -> mdt:TabStrip… I get an error saying

Error: Building UI from XML. @app-root.xml:16:9 Cannot read property 'context' of undefined

This used to work without a problem (I have no idea what changed) and in fact, on iOS it's working perfectly. Alas, it only worked before without the «MD»-Part in tab-strip -> <mdt:TabStrip…>

Any ideas what I'm doing wrong?

Is there any code involved?

This creates the error Module '@nativescript-community/ui-material-bottom-navigation' not found for element '@nativescript-community/ui-material-bottom-navigation:MDTabStrip'

<Page xmlns:mdt="@nativescript-community/ui-material-bottom-navigation">
<mdt:BottomNavigation id="bottomNavigation" selectedIndex="0" loaded="tabStripLoaded">
    <mdt:MDTabStrip tabBackgroundColor="#dfdfdf">
        <mdt:MDTabStripItem class="navigation__item">
            <Label class="tab" text="Home" />
            <Image src="font://&#xf015;" class="fas t-36 tab" />
        </mdt:MDTabStripItem>
        <mdt:MDTabStripItem class="navigation__item">
            <Label class="tab" text="Info/Impressum" />
            <Image src="font://&#xf05a;" class="fas fa-info-circle tab" />
        </mdt:MDTabStripItem>

    </mdt:MDTabStrip>

    <mdt:MDTabContentItem>
        <Frame id="firstFrame" defaultPage="home/home-items-page" />
    </mdt:MDTabContentItem>

    <mdt:MDTabContentItem>
        <Frame id="secondFrame"  defaultPage="impressum/impressum-page" />
    </mdt:MDTabContentItem>

</mdt:BottomNavigation>
</Page>

This creates the error Error: Building UI from XML. @app-root.xml:16:9 Cannot read property 'context' of undefined

<Page xmlns:mdt="@nativescript-community/ui-material-bottom-navigation">
<mdt:BottomNavigation id="bottomNavigation" selectedIndex="1" loaded="tabStripLoaded">
    <mdt:TabStrip tabBackgroundColor="#dfdfdf">
        <mdt:TabStripItem class="navigation__item">
            <Label class="tab" text="Home" />
            <Image src="font://&#xf015;" class="fas t-36 tab" />
        </mdt:TabStripItem>
        <mdt:TabStripItem class="navigation__item">
            <Label class="tab" text="Info/Impressum" />
            <Image src="font://&#xf05a;" class="fas fa-info-circle tab" />
        </mdt:TabStripItem>

    </mdt:TabStrip>

    <mdt:TabContentItem>
        <Frame id="firstFrame" defaultPage="home/home-items-page" />
    </mdt:TabContentItem>

    <mdt:TabContentItem>
        <Frame id="secondFrame"  defaultPage="impressum/impressum-page" />
    </mdt:TabContentItem>

</mdt:BottomNavigation>
</Page>

And again, just to clarify - the second code works on iOS. The problem only occurs on Android.

farfromrefug commented 2 years ago

@update-switzerland i think you need to use TabStrip because of the way N xml core works (not 100% sure as i dont use it). I think you need to look at your second error which is an android error. Though i cant help without more stacktrace

update-switzerland commented 2 years ago

Thanks - would this be enough? (it's what I get in the console - I have no idea how to get a full stack-trace)

System.err: Caused by: com.tns.NativeScriptException: Calling js method onCreate failed System.err: Error: Building UI from XML. @app-root.xml:16:9 System.err: > Cannot read property 'context' of undefined System.err: at com.tns.Runtime.callJSMethodNative(Native Method) System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1302) System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1188) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1175) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1153) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1149) System.err: at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:29) System.err: at android.app.Activity.performCreate(Activity.java:6251) System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) System.err: ... 9 more ActivityManager: Process ch.ktipp.testsieger (pid 7532) has died ActivityManager: cleanUpApplicationRecord -- 7532

farfromrefug commented 2 years ago

@update-switzerland it is better but does not give much :s i dont know where the error is happening with this. Maybe you can share on discord and see if someone have an idea?

update-switzerland commented 2 years ago

Thanks @farfromrefug - I found the culprit.

It was a plugin (specifically nativescript-in-app-purchase) that caused the error.

I was able to fix it in the meantime.