Hasan Triuman Tekin
Hasan Triuman Tekin

Reputation: 71

java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup Nativescript-Angular

I added side drawer plugin to my NativeScript-Angular project. My app.component.html is as follows:

<RadSideDrawer>
   <GridLayout tkDrawerContent rows="auto, *" class="sidedrawer sidedrawer-left">
      <StackLayout row="0" style="margin-bottom: 30px;">
         <StackLayout orientation="horizontal" style="padding: 13px 20px;">
            <label text="Hasan Tekin" textWrap="false" style="font-size: 20px;color: white;margin: 20 30 10 10;"></label>
         </StackLayout>
      </StackLayout>
      <ScrollView row="1">
         <StackLayout class="sidedrawer-content">
            <StackLayout *ngFor="let item of state.sideDrawer.items; let i = index">
               <StackLayout orientation="horizontal" style="padding: 13px 0;" (tap)="activateMenuItem(i)" [routerLink]="['/mysurveys']">
                  <Image [src]="item.active ? '~/assets/images/arrowGreen.png' : '~/assets/images/arrowGray.png'" style="width: 40px;margin: 0 20px;"></Image>
                  <label text={{item.text}} textWrap="false" [class]="item.active ? 'menuItemActive' : 'menuItem'"></label>
               </StackLayout>
               <StackLayout class="hr-dark m-10">
               </StackLayout>
            </StackLayout>
         </StackLayout>
      </ScrollView>
   </GridLayout>

   <page-router-outlet tkMainContent class="page page-content"></page-router-outlet>
</RadSideDrawer>

When I run tns run android --bundle, it gives me this error:

Error: java.lang.IllegalArgumentException: Cannot add a null child view to a ViewGroup

What could be the reason?

Upvotes: 1

Views: 2387

Answers (1)

Hasan Triuman Tekin
Hasan Triuman Tekin

Reputation: 71

It was totally my mistake. I had imported side drawer in app.module.ts instead of app.module.tns.ts. Now I removed that import and write it to app.module.tns.ts and it works.

Upvotes: 2

Related Questions