triniwiz / nativescript-accordion

Apache License 2.0
38 stars 14 forks source link

"Calling js method getGroupView failed" in Angular-NS #42

Closed LeoDupont closed 6 years ago

LeoDupont commented 6 years ago

Hello,

I get the following error on a simple Angular-NS project:

com.tns.NativeScriptException:
Calling js method getGroupView failed

TypeError: Cannot read property 'setBackgroundColor' of undefined
File: "file:///data/data/org.nativescript.CDC/files/app/tns_modules/nativescript-accordion/src/android/accordion.js, line: 251, column: 30

StackTrace:
    Frame: function:'AccordionListAdapter.getGroupView', file:'file:///data/data/org.nativescript.CDC/files/app/tns_modules/nativescript-accordion/src/android/accordion.js', line: 251, column: 31

    at com.tns.Runtime.callJSMethodNative(Native Method)
    at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116)
    at com.tns.Runtime.callJSMethodImpl(Runtime.java:996)
    at com.tns.Runtime.callJSMethod(Runtime.java:983)
    at com.tns.Runtime.callJSMethod(Runtime.java:967)
    at com.tns.Runtime.callJSMethod(Runtime.java:959)
    at com.tns.gen.android.widget.BaseExpandableListAdapter_accordion_209_28_AccordionListAdapter.getGroupView(BaseExpandableListAdapter_accordion_209_28_AccordionListAdapter.java:38)
    at android.widget.ExpandableListConnector.getView(ExpandableListConnector.java:446)
    at android.widget.AbsListView.obtainView(AbsListView.java:2372)
    at android.widget.ListView.measureHeightOfChildren(ListView.java:1408)
    at android.widget.ListView.onMeasure(ListView.java:1315)
    at android.view.View.measure(View.java:22002)
    at org.nativescript.widgets.CommonLayoutParams.measureChild(CommonLayoutParams.java:262)
    at org.nativescript.widgets.StackLayout.onMeasure(StackLayout.java:83)
    at android.view.View.measure(View.java:22002)
    at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1629)
    at android.view.View.measure(View.java:22002)
    at org.nativescript.widgets.CommonLayoutParams.measureChild(CommonLayoutParams.java:262)
    at org.nativescript.widgets.MeasureHelper.measureChildFixedColumnsAndRows(GridLayout.java:1055)
    at org.nativescript.widgets.MeasureHelper.measure(GridLayout.java:865)
    at org.nativescript.widgets.GridLayout.onMeasure(GridLayout.java:279)
    at android.view.View.measure(View.java:22002)
    at org.nativescript.widgets.CommonLayoutParams.measureChild(CommonLayoutParams.java:262)
    at org.nativescript.widgets.MeasureHelper.measureChildFixedColumnsAndRows(GridLayout.java:1055)
    at org.nativescript.widgets.MeasureHelper.measure(GridLayout.java:865)
    at org.nativescript.widgets.GridLayout.onMeasure(GridLayout.java:279)
    at android.view.View.measure(View.java:22002)
    at org.nativescript.widgets.CommonLayoutParams.measureChild(CommonLayoutParams.java:262)
    at org.nativescript.widgets.MeasureHelper.measureChildFixedColumnsAndRows(GridLayout.java:1055)
    at org.nativescript.widgets.MeasureHelper.measure(GridLayout.java:865)
    at org.nativescript.widgets.GridLayout.onMeasure(GridLayout.java:279)
    at android.view.View.measure(View.java:22002)
    at org.nativescript.widgets.CommonLayoutParams.measureChild(CommonLayoutParams.java:262)
    at org.nativescript.widgets.ContentLayout.onMeasure(ContentLayout.java:32)
    at android.view.View.measure(View.java:22002)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.view.View.measure(View.java:22002)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.view.View.measure(View.java:22002)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.view.View.measure(View.java:22002)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
    at android.view.View.measure(View.java:22002)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at com.android.internal.policy.DecorView.onMeasure(DecorView.java:721)
    at android.view.View.measure(View.java:22002)
    at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2410)
    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1498)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1751)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1386)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6733)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
    at android.view.Choreographer.doCallbacks(Choreographer.java:723)
    at android.view.Choreographer.doFrame(Choreographer.java:658)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6541)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Here is my HTML template:

<Accordion [items]="myItems" itemTapped="tapped" headerTextBold="true" headerTextColor="gray" headerColor="blue" allowMultiple="true" selectedIndex="2">

    <ng-template accordionHeaderTemplate let-item="item" let-i="index">
        <GridLayout>
            <Label [text]="item.name"></Label>
        </GridLayout>
    </ng-template>

    <ng-template accordionItemTemplate let-item="item" let-parent="parentIndex" let-even="even" let-child="childIndex">
        <GridLayout>
            <Label [text]="item.text"></Label>
        </GridLayout>
    </ng-template>

</Accordion>

I first tried with this myItems array:

public myItems = [
    { name: "Name 1", text: "Text 1" },
    { name: "Name 2", text: "Text 2" },
];

Then I tried to copy the README's array:

public myItems = [
    {
        title: "1", footer: "10", headerText: "First", footerText: "4",
        items: [
            { name: "Name 1", text: "Text 1" },
            { name: "Name 2", text: "Text 2" },
        ]
    }
]

But I had no luck with both. What am I doing wrong?