-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crashes Android app on NS8 #269
Comments
Hi @EddyVerbruggen thank you for this great plugin! I am unfortunately having the same issue since moving to NativeScript 8 on Android. As soon as the camera opens the app crashes: System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onViewAttachedToWindow failed
System.err: TypeError: activity.getLifecycle is not a function
System.err:
System.err: StackTrace:
System.err: _onAttachedToWindow(file: src\webpack:\mobile\node_modules\@nativescript-community\ui-material-bottom-navigation\index.android.js:307:0)
System.err: at AttachListener.onViewAttachedToWindow(file: src\webpack:\mobile\node_modules\@nativescript-community\ui-material-bottom-navigation\index.android.js:157:0)
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.gen.java.lang.Object_vendor_576_28_AttachListener.onViewAttachedToWindow(Object_vendor_576_28_AttachListener.java:18)
System.err: at android.view.View.dispatchAttachedToWindow(View.java:18418)
System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3407)
System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3414)
System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3414)
System.err: at android.view.ViewGroup.addViewInner(ViewGroup.java:5091)
System.err: at android.view.ViewGroup.addView(ViewGroup.java:4879)
System.err: at android.view.ViewGroup.addView(ViewGroup.java:4819)
System.err: at android.view.ViewGroup.addView(ViewGroup.java:4792)
System.err: at android.view.ViewOverlay$OverlayViewGroup.add(ViewOverlay.java:205)
System.err: at android.view.ViewGroupOverlay.add(ViewGroupOverlay.java:72)
System.err: at androidx.transition.ViewGroupOverlayApi18.add(ViewGroupOverlayApi18.java:48)
System.err: at androidx.transition.Visibility.onDisappear(Visibility.java:428)
System.err: at androidx.transition.Visibility.createAnimator(Visibility.java:257)
System.err: at androidx.transition.Transition.createAnimators(Transition.java:747)
System.err: at androidx.transition.TransitionSet.createAnimators(TransitionSet.java:480)
System.err: at androidx.transition.Transition.playTransition(Transition.java:1821)
System.err: at androidx.transition.TransitionManager$MultiListener.onPreDraw(TransitionManager.java:301)
System.err: at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:977)
System.err: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2502)
System.err: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1479)
System.err: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7211)
System.err: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
System.err: at android.view.Choreographer.doCallbacks(Choreographer.java:761)
System.err: at android.view.Choreographer.doFrame(Choreographer.java:696)
System.err: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
System.err: at android.os.Handler.handleCallback(Handler.java:873)
System.err: at android.os.Handler.dispatchMessage(Handler.java:99)
System.err: at android.os.Looper.loop(Looper.java:193)
System.err: at android.app.ActivityThread.main(ActivityThread.java:6880)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:504)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) |
@rob4226 Have you found a solution to this yet? Not sure if @EddyVerbruggen is still maintaining this repo or not. |
@delanick I found that it is caused by some interaction between this barcode-scanner plugin and the @nativescript-community/ui-material-bottom-navigation plugin. Specifically, the error occurs when I am not sure what the exact problem is, or why it happens, but as a hack I added a check for the if ((this._manager && this._manager.isDestroyed()) || (activity.hasOwnProperty('getLifecycle') && !activity.getLifecycle().getCurrentState().isAtLeast(androidx.lifecycle.Lifecycle.State.STARTED))) {
return;
} Note the addtional |
@rob4226 that's awesome that you found a hack, well done and thank you for sharing! Which file do I make those changes on? |
@delanick Np, I hope it works for you. We should probably follow up on this in the bottom-drawer plugin repo so maybe they can address it. The file is located in the bottom-navigation plugin so in your project: You can try it first there to make sure it works for you but if it does, you are probably better off cloning that repo, then making the change in |
@rob4226 thanks so much, got it working. My file was different to yours as I have bottom nav installed separately. But it works, which is what matters. As for your other point, yep, exactly that - will need to clone and build the plugin myself. Issue is, I'm a noob when it comes to plugins, so have no idea how to build it. Any advice? |
You can
Update
and run
|
Hi @EddyVerbruggen
Since moving to NS8, this plugin crashes the Android version of my app. Works perfectly fine on iOS. Errors received are:
System.err: An uncaught Exception occurred on "main" thread. System.err: Calling js method onViewAttachedToWindow failed System.err: TypeError: activity.getLifecycle is not a function System.err: System.err: StackTrace: System.err: _onAttachedToWindow(file: app/webpack:/wesignit/node_modules/@nativescript-community/ui-material-bottom-navigation/index.android.js:307:0) System.err: at AttachListener.onViewAttachedToWindow(file: app/webpack:/wesignit/node_modules/@nativescript-community/ui-material-bottom-navigation/index.android.js:157:0) 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.gen.java.lang.Object_vendor_177_28_AttachListener.onViewAttachedToWindow(Object_vendor_177_28_AttachListener.java:18) System.err: at android.view.View.dispatchAttachedToWindow(View.java:18637) System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3520) System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3527) System.err: at android.view.ViewGroup.addViewInner(ViewGroup.java:5162) System.err: at android.view.ViewGroup.addView(ViewGroup.java:4953) System.err: at android.view.ViewGroup.addView(ViewGroup.java:4893) System.err: at android.view.ViewGroup.addView(ViewGroup.java:4866) System.err: at android.view.ViewOverlay$OverlayViewGroup.add(ViewOverlay.java:205) System.err: at android.view.ViewGroupOverlay.add(ViewGroupOverlay.java:72) System.err: at androidx.transition.ViewGroupOverlayApi18.add(ViewGroupOverlayApi18.java:48) System.err: at androidx.transition.Visibility.onDisappear(Visibility.java:428) System.err: at androidx.transition.Visibility.createAnimator(Visibility.java:257) System.err: at androidx.transition.Transition.createAnimators(Transition.java:747) System.err: at androidx.transition.TransitionSet.createAnimators(TransitionSet.java:480) System.err: at androidx.transition.Transition.playTransition(Transition.java:1821) System.err: at androidx.transition.TransitionManager$MultiListener.onPreDraw(TransitionManager.java:301) System.err: at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1045) System.err: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2813) System.err: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1785) System.err: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7832) System.err: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911) System.err: at android.view.Choreographer.doCallbacks(Choreographer.java:723) System.err: at android.view.Choreographer.doFrame(Choreographer.java:658) System.err: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897) System.err: at android.os.Handler.handleCallback(Handler.java:789) System.err: at android.os.Handler.dispatchMessage(Handler.java:98) System.err: at android.os.Looper.loop(Looper.java:164) System.err: at android.app.ActivityThread.main(ActivityThread.java:6944) System.err: at java.lang.reflect.Method.invoke(Native Method) System.err: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
I don't know what any of that means and thus not able to fix it.
My
package.json
looks as follows:"dependencies": { "@nativescript-community/ui-material-bottom-navigation": "^5.3.5", "@nativescript/core": "~8.0.0", "@nativescript/social-share": "^2.0.4", "@nativescript/theme": "~3.0.1", "@nstudio/nativescript-exoplayer": "^5.0.6", "nativescript-appversion": "^1.4.4", "nativescript-barcodescanner": "^4.1.1", "nativescript-bottom-navigation": "^2.0.5", "nativescript-iqkeyboardmanager": "^1.5.1", "nativescript-material-icons": "^1.0.3", "nativescript-pushy": "^2.1.0" }, "devDependencies": { "@nativescript/android": "8.0.0", "@nativescript/ios": "8.0.0", "@nativescript/types": "8.0.0", "@nativescript/webpack": "~5.0.0-beta.0", "eslint": "~7.7.0", "node-sass": "^4.14.1"
The text was updated successfully, but these errors were encountered: