Comments (7)
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)
from nativescript-barcodescanner.
@rob4226 Have you found a solution to this yet?
Not sure if @EddyVerbruggen is still maintaining this repo or not.
from nativescript-barcodescanner.
@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 activity.getLifecycle()
is called:
I am not sure what the exact problem is, or why it happens, but as a hack I added a check for the getLifecycle()
function before calling it, which seems to have allowed everything to work. I changed lines 406 - 408 to:
if ((this._manager && this._manager.isDestroyed()) || (activity.hasOwnProperty('getLifecycle') && !activity.getLifecycle().getCurrentState().isAtLeast(androidx.lifecycle.Lifecycle.State.STARTED))) {
return;
}
Note the addtional activity.hasOwnProperty('getLifecycle') &&
check. Although this makes it work, I don't know if it is the proper solution for it. Any idea's anyone??
from nativescript-barcodescanner.
@rob4226 that's awesome that you found a hack, well done and thank you for sharing! Which file do I make those changes on?
from nativescript-barcodescanner.
@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: node_modules/@nativescript-community/ui-material-bottom-navigation/index.android.js
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 src/bottom-navigation/index.android.ts
and building the plugin, then install it locally in your project so the change will be permanent. Otherwise, every time you run npm install
for you project, your changes in your node_modules
will be overwritten.
from nativescript-barcodescanner.
@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?
from nativescript-barcodescanner.
You can
Clone the project
cd NativeScript/plugins
git clone [email protected]:EddyVerbruggen/nativescript-barcodescanner.git
cd nativescript-barcodescanner
-- Optional: apply PR 278 to prevent iOS full screen crashes - requires Github CLI --
gh pr checkout 278
cd src
-- change version to 4.1.3 in package.json --
npm run build
cd publish
./pack.sh
mv package/nativescript-barcodescanner-4.1.3.tgz ~/my-app-folder/plugins
Update package.json
to use local file
"nativescript-barcodescanner": "file:plugins/nativescript-barcodescanner-4.1.3.tgz",
and run
ns clean
npm i
from nativescript-barcodescanner.
Related Issues (20)
- Scanned QR code does not update property HOT 1
- Creating Dialog.alert inside .then((result) not working HOT 5
- class definition conflicts HOT 1
- can it scan a qr picture saved in storage?
- options to avoid page reloading upon scanning HOT 1
- [iOS] Crash with NativeScript 8 and JSC runtime HOT 1
- Preview on iOS fails with JS exception which crashes the app.
- "The webpack configuration file ...webpack.config.js does not exist" while trying demo HOT 1
- warning: skipping copy phase strip, binary is code signed HOT 1
- Objective-C class name "UIScrollViewDelegateImpl" is already in use - using "UIScrollViewDelegateImpl1" instead.
- Opening the camera for a barcode scan crashes the app on iOS HOT 3
- Invoking barcode scanner causes application crash on latest NativeScript ios platform (8.1.0) HOT 13
- Scanning with a scanner HOT 2
- Add Button in Activity Scanner Android
- Error: Command xcodebuild failed with exit code 65 on Apple Silicon (M1) HOT 3
- Crash all Frames in application after a scan done! HOT 1
- Can this plugin pick QR from image?
- Build target issue: iOS vs iOS + iOS Simulator HOT 2
- Crash at startup on Android in release mode HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nativescript-barcodescanner.