Error on Nativescript Custom dialogue: JS: ERROR Error: Uncaught (in promise): Error: java.lang.NullPointerException: A ttempt to invoke virtual method 'android.os.Looper android.content.Context.getMa inLooper()' on a null object reference


#1

In my app I am implementing custom dialog. I followed the tutorial here. As per the tutorial, while calling “this.modal.showModal” function I am getting a functioning modal box, however there is a error on my console. (See Below): Please let me know what the problem could be.
FYI: The error is occurring on android physical device.

JS: ERROR Error: Uncaught (in promise): Error: java.lang.NullPointerException: A
ttempt to invoke virtual method 'android.os.Looper android.content.Context.getMainLooper()' on a null object reference
JS:     miui.util.AttributeResolver.u(SourceFile:35)
JS:     miui.util.AttributeResolver.resolveInt(SourceFile:145)
JS:     miui.util.AttributeResolver.isUsingMiuiTheme(SourceFile:179)
JS:     miui.os.Environment.isUsingMiui(SourceFile:99)
JS:     android.view.ViewConfigurationInjector.get(ViewConfigurationInjector.jav
a:18)
JS:     android.view.ViewConfiguration.get(ViewConfiguration.java:369)
JS:     android.view.View.<init>(View.java:3795)
JS:     android.view.View.<init>(View.java:3899)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:574)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:570)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:566)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:562)
JS:     org.nativescript.widgets.LayoutBase.<init>(LayoutBase.java:20)
JS:     org.nativescript.widgets.GridLayout.<init>(GridLayout.java:28)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:912)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:896)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:888)
JS:     com.tns.gen.java.lang.Runnable.run(Runnable.java:10)
JS:     android.os.Handler.handleCallback(Handler.java:742)
JS:     android.os.Handler.dispatchMessage(Handler.java:95)
JS:     android.os.Looper.loop(Looper.java:154)
JS:     android.app.ActivityThread.main(ActivityThread.java:5527)
JS:     java.lang.reflect.Method.invoke(Native Method)
JS:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.ja
va:739)
JS:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
JS: Error: java.lang.NullPointerException: Attempt to invoke virtual method 'and
roid.os.Looper android.content.Context.getMainLooper()' on a null object referen
ce
JS:     miui.util.AttributeResolver.u(SourceFile:35)
JS:     miui.util.AttributeResolver.resolveInt(SourceFile:145)
JS:     miui.util.AttributeResolver.isUsingMiuiTheme(SourceFile:179)
JS:     miui.os.Environment.isUsingMiui(SourceFile:99)
JS:     android.view.ViewConfigurationInjector.get(ViewConfigurationInjector.jav
a:18)
JS:     android.view.ViewConfiguration.get(ViewConfiguration.java:369)
JS:     android.view.View.<init>(View.java:3795)
JS:     android.view.View.<init>(View.java:3899)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:574)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:570)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:566)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:562)
JS:     org.nativescript.widgets.LayoutBase.<init>(LayoutBase.java:20)
JS:     org.nativescript.widgets.GridLayout.<init>(GridLayout.java:28)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:912)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:896)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:888)
JS:     com.tns.gen.java.lang.Runnable.run(Runnable.java:10)
JS:     android.os.Handler.handleCallback(Handler.java:742)
JS:     android.os.Handler.dispatchMessage(Handler.java:95)
JS:     android.os.Looper.loop(Looper.java:154)
JS:     android.app.ActivityThread.main(ActivityThread.java:5527)
JS:     java.lang.reflect.Method.invoke(Native Method)
JS:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.ja
va:739)
JS:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
JS:     at Page.createNativeView (file:///data/data/org.nativescript.qbank/files
/app/tns_modules/tns-core-modules/ui/page/page.js:82:22)
JS:     at Page.ViewBase._setupUI (file:///data/data/org.nativescript.qbank/file
s/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:529:35)
JS:     at Page._showNativeModalView (file:///data/data/org.nativescript.qbank/f
iles/app/tns_modules/tns-core-modules/ui/page/page.js:1
JS: 27:14)
JS:     at PageBase.showModal (file:///data/data/org.nativescript.qbank/files/ap
p/tns_modules/tns-core-modules/ui/page/page-common.js:186:18)
JS:     at file:///data/data/org.nativescript.qbank/files/app/tns_modules/native
script-angular/directives/dialogs.js:72:24
JS:     at ZoneDelegate.invoke (file:///data/data/org.nativescript.qbank/files/a
pp/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:365:26)
JS:     at Object.onInvoke (file:///data/data/org.nativescript.qbank/files/app/t
ns_modules/@angular/core/bundles/core.umd.js:4156:37)
JS:     at ZoneDelegate.invoke (file:///data/data/org.nativescript.qbank/files/a
pp/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:364:32)
JS:     at Zone.run (file:///data/data/org.nativescript.qbank/files/app/tns_modu
les/nativescript-angular/zone-js/dist/zone-nativescript.js:125:43)
JS:     at file:///data/data/org.nativescript.qbank/files/app/tns_modules/native
script-angular/zone-js/dist/zone-nativescript.js:760:57
JS:     at ZoneDelegate.invokeTask (file:///data/data/org.nativescript.qbank/fil
es/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:398:31
)
JS:     at Object.onInvokeTask (file:///data/data/org.nativescript.qbank/files/a
pp/tns_modules/@angular/core/bundles/core.umd.js:4147:37)
JS:     at ZoneDelegate.invokeTask (file:///data/data/org.nativescript.qbank/fil
es/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:397:36
)
JS:     at Zone.runTask (file:///data/data/org.nativescript.qbank/files/app/tns_
modules/nativescript-angular/zone-js/dist/zone-nativescript.js:165:47)
JS:     at drainMicroTaskQueue (file:///data/data/org.nativescript.qbank/files/a
pp/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:593:35)
JS: ERROR Error: Uncaught (in promise): Error: java.lang.NullPointerException: A
ttempt to invoke virtual method 'android.os.Looper android.content.Context.getMa
inLooper()' on a null object reference
JS:     miui.util.AttributeResolver.u(SourceFile:35)
JS:     miui.util.AttributeResolver.resolveInt(SourceFile:145)
JS:     miui.util.AttributeResolver.isUsingMiuiTheme(SourceFile:179)
JS:     miui.os.Environment.isUsingMiui(SourceFile:99)
JS:     android.view.ViewConfigurationInjector.get(ViewConfigurationInjector.jav
a:18)
JS:     android.view.ViewConfiguration.get(ViewConfiguration.java:369)
JS:     android.view.View.<init>(View.java:3795)
JS:     android.view.View.<init>(View.java:3899)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:574)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:570)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:566)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:562)
JS:     org.nativescript.widgets.LayoutBase.<init>(LayoutBase.java:20)
JS:     org.nativescript.widgets.GridLayout.<init>(GridLayout.java:28)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:912)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:896)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:888)
JS:     com.tns.gen.java.lang.Runnable.run(Runnable.java:10)
JS:     android.os.Handler.handleCallback(Handler.java:742)
JS:     android.os.Handler.dispatchMessage(Handler.java:95)
JS:     android.os.Looper.loop(Looper.java:154)
JS:     android.app.ActivityThread.main(ActivityThread.java:5527)
JS:     java.lang.reflect.Method.invoke(Native Method)
JS:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.ja
va:739)
JS:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
JS: Error: java.lang.NullPointerException: Attempt to invoke virtual method 'and
roid.os.Looper android.content.Context.getMainLooper()' on a null object referen
ce
JS:     miui.util.AttributeResolver.u(SourceFile:35)
JS:     miui.util.AttributeResolver.resolveInt(SourceFile:145)
JS:     miui.util.AttributeResolver.isUsingMiuiTheme(SourceFile:179)
JS:     miui.os.Environment.isUsingMiui(SourceFile:99)
JS:     android.view.ViewConfigurationInjector.get(ViewConfigurationInjector.jav
a:18)
JS:     android.view.ViewConfiguration.get(ViewConfiguration.java:369)
JS:     android.view.View.<init>(View.java:3795)
JS:     android.view.View.<init>(View.java:3899)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:574)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:570)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:566)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:562)
JS:     org.nativescript.widgets.LayoutBase.<init>(LayoutBase.java:20)
JS:     org.nativescript.widgets.GridLayout.<init>(GridLayout.java:28)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:912)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:896)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:888)
JS:     com.tns.gen.java.lang.Runnable.run(Runnable.java:10)
JS:     android.os.Handler.handleCallback(Handler.java:742)
JS:     android.os.Handler.dispatchMessage(Handler.java:95)
JS:     android.os.Looper.loop(Looper.java:154)
JS:     android.app.ActivityThread.main(ActivityThread.java:5527)
JS:     java.lang.reflect.Method.invoke(Native Method)
JS:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.ja
va:739)
JS:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
JS:     at Page.createNativeView (file:///data/data/org.nativescript.qbank/files
/app/tns_modules/tns-core-modules/ui/page/page.js:82:22)
JS:     at Page.ViewBase._setupUI (file:///data/data/org.nativescript.qbank/file
s/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:529:35)
JS:     at Page._showNativeModalView (file:///data/data/org.nativescript.qbank/f
iles/app/tns_modules/tns-core-modules/ui/page/page.js:1
JS: 27:14)
JS:     at PageBase.showModal (file:///data/data/org.nativescript.qbank/files/ap
p/tns_modules/tns-core-modules/ui/page/page-common.js:186:18)
JS:     at file:///data/data/org.nativescript.qbank/files/app/tns_modules/native
script-angular/directives/dialogs.js:72:24
JS:     at ZoneDelegate.invoke (file:///data/data/org.nativescript.qbank/files/a
pp/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:365:26)
JS:     at Object.onInvoke (file:///data/data/org.nativescript.qbank/files/app/t
ns_modules/@angular/core/bundles/core.umd.js:4156:37)
JS:     at ZoneDelegate.invoke (file:///data/data/org.nativescript.qbank/files/a
pp/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:364:32)
JS:     at Zone.run (file:///data/data/org.nativescript.qbank/files/app/tns_modu
les/nativescript-angular/zone-js/dist/zone-nativescript.js:125:43)
JS:     at file:///data/data/org.nativescript.qbank/files/app/tns_modules/native
script-angular/zone-js/dist/zone-nativescript.js:760:57
JS:     at ZoneDelegate.invokeTask (file:///data/data/org.nativescript.qbank/fil
es/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:398:31
)
JS:     at Object.onInvokeTask (file:///data/data/org.nativescript.qbank/files/a
pp/tns_modules/@angular/core/bundles/core.umd.js:4147:37)
JS:     at ZoneDelegate.invokeTask (file:///data/data/org.nativescript.qbank/fil
es/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:397:36
)
JS:     at Zone.runTask (file:///data/data/org.nativescript.qbank/files/app/tns_
modules/nativescript-angular/zone-js/dist/zone-nativescript.js:165:47)
JS:     at drainMicroTaskQueue (file:///data/data/org.nativescript.qbank/files/a
pp/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:593:35)


#2
<Button (tap)="submit()" text="cancel"></Button>

<StackLayout *ngIf="isFacebookNotShared | async">
    <facebook-button (facebookShared)="facebookShared($event)" [design]="2" [item]="activity | async"></facebook-button>
</StackLayout>

<StackLayout *ngIf="isTwitterNotShared | async">
    <twitter-button (twitterShared)="twitterShared($event)" [design]="2" [item]="activity | async" ></twitter-button>
</StackLayout>

#3

I commented out the whole code keeping only a stackLayout with a label but the issue remains the same