nativescript-community / nativescript-drawingpad

:pencil: NativeScript plugin to provide a way to capture any drawing (signatures are a common use case) from the device
Apache License 2.0
90 stars 32 forks source link

{N}-Vue error when getDrawing() is called #42

Open rigoparis opened 6 years ago

rigoparis commented 6 years ago

Please let me know if there's a template for reporting errors, I didn't find one

Hey guys!

First of all, thanks for the awesome plugin!

Now, I'm having an issue while calling getDrawing().

XML:

<DrawingPad ref="dibujo" height="50%" class="bordeado"/>

JS:

this.$refs.dibujo._nativeView.getDrawing()
    .then(res => console.log(res))
    .catch(err => console.log(err));

this returns the error at the bottom. However, if I use getDrawingSvg() it successfully returns the SVGXML and I can work with that... but just curious onto why this is happening.

[Error: java.lang.NoSuchFieldError: no "Landroid/graphics/Bitmap$Config;" field "HARDWARE" in class "Landroid/graphics/Bitmap$Config;" or its superclasses
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1097)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:979)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:966)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:950)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:942)
JS:     com.tns.gen.java.lang.Object_view_30_32_TouchListenerImpl.onTouch(Object_view_30_32_TouchListenerImpl.java:18)
JS:     android.view.View.dispatchTouchEvent(View.java:8281)
JS:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2324)
JS:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2064)
JS:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2324)
JS:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2064)
JS:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2324)
JS:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2064)
JS:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2324)
JS:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2064)
JS:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2324)
JS:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2064)
JS:     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2324)
JS:     android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2064)
JS:     com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2327)
JS:     com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1705)
JS:     android.app.Dialog.dispatchTouchEvent(Dialog.java:807)
JS:     com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2288)
JS:     android.view.View.dispatchPointerEvent(View.java:8477)
JS:     android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4281)
JS:     android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4147)
JS:     android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3652)
JS:     android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3705)
JS:     android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3671)
JS:     android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3781)
JS:     android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3679)
JS:     android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3838)
JS:     android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3652)
JS:     android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3705)
JS:     android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3671)
JS:     android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3679)
JS:     android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3652)
JS:     android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5961)
JS:     android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5935)
JS:     android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5906)
JS:     android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6062)
JS:     android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
JS:     android.os.MessageQueue.nativePollOnce(Native Method)
JS:     android.os.MessageQueue.next(MessageQueue.java:143)
JS:     android.os.Looper.loop(Looper.java:122)
JS:     android.app.ActivityThread.main(ActivityThread.java:5538)
JS:     java.lang.reflect.Method.invoke(Native Method)
JS:     java.lang.reflect.Method.invoke(Method.java:372)
JS:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
JS:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)]
bradmartin commented 6 years ago

Could be an API change in android. What API are you running on? If you could upload a demo project I'd be able to help run it locally and find a fix also 😄

rigoparis commented 6 years ago

Hey @bradmartin, thanks for the response.

I'm using 26.1.0 (this has to stay because it was the only version I found compatible with both geolocation and push notifications)

This is a playground I've set up using what I'm using a basic level. The playground crashes when I run the app with the following error but hopefully it will be enough to understand whats going on.

On the PG I tried importing the package with several different ways... but I got the closest with what I posted on the PG.

Playground: https://play.nativescript.org/?template=play-vue&id=aDdNWM

Error:

[ALE-L23]: An uncaught Exception occurred on "main" thread.
com.tns.NativeScriptException: 
Calling js method onCreateView failed

TypeError: Cannot read property 'gcacace' of undefined
File: "file:///data/data/org.nativescript.preview/files/app/nativescript-drawingpad/drawingpad.js, line: 17, column: 42

StackTrace: 
Frame: function:'DrawingPad.createNativeView', file:'file:///data/data/org.nativescript.preview/files/app/nativescript-drawingpad/drawingpad.js', line: 17, column: 43
Frame: function:'ViewBase._setupUI', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 492, column: 35
Frame: function:'', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 534, column: 19
Frame: function:'LayoutBaseCommon.eachChildView', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js', line: 125, column: 26
Frame: function:'ViewCommon.eachChild', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 868, column: 14
Frame: function:'ViewBase._setupUI', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 533, column: 14
Frame: function:'', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 534, column: 19
Frame: function:'ContentView.eachChildView', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/content-view/content-view.js', line: 70, column: 13
Frame: function:'ViewCommon.eachChild', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 868, column: 14
Frame: function:'ViewBase._setupUI', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 533, column: 14
Frame: function:'', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 534, column: 19
Frame: function:'ContentView.eachChildView', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/content-view/content-view.js', line: 70, column: 13
Frame: function:'PageBase.eachChildView', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/page/page-common.js', line: 120, column: 40
Frame: function:'ViewCommon.eachChild', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 868, column: 14
Frame: function:'ViewBase._setupUI', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 533, column: 14
Frame: function:'ViewBase._addViewCore', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 431, column: 18
Frame: function:'ViewBase._addView', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 420, column: 14
Frame: function:'FragmentCallbacksImplementation.onCreateView', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 588, column: 24
Frame: function:'FragmentClass.onCreateView', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/frame/fragment.js', line: 27, column: 38

at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
at com.tns.Runtime.callJSMethod(Runtime.java:970)
at com.tns.Runtime.callJSMethod(Runtime.java:954)
at com.tns.Runtime.callJSMethod(Runtime.java:946)
at com.tns.FragmentClass.onCreateView(FragmentClass.java:45)
at android.app.Fragment.performCreateView(Fragment.java:2059)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:899)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1076)
at android.app.BackStackRecord.run(BackStackRecord.java:833)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1461)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:448)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5538)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
bradmartin commented 6 years ago

I don't think the playground supports dependencies with native libraries. Unless it's been updated recently. So you can't use a lot of plugins in the playground because of this. Let me know if you can do a local project just fine. I did a few weeks ago so it should be fine.

On Tue, Jun 26, 2018, 10:18 AM rigoparis notifications@github.com wrote:

Hey @bradmartin https://github.com/bradmartin, thanks for the response.

I'm using 26.1.0 (this has to stay because it was the only version I found compatible with both geolocation and push notifications)

This is a playground I've set up using what I'm using a basic level. The playground crashes when I run the app with the following error.

Playground: https://play.nativescript.org/?template=play-vue&id=aDdNWM

Error:

[ALE-L23]: An uncaught Exception occurred on "main" thread. com.tns.NativeScriptException: Calling js method onCreateView failed

TypeError: Cannot read property 'gcacace' of undefined File: "file:///data/data/org.nativescript.preview/files/app/nativescript-drawingpad/drawingpad.js, line: 17, column: 42

StackTrace: Frame: function:'DrawingPad.createNativeView', file:'file:///data/data/org.nativescript.preview/files/app/nativescript-drawingpad/drawingpad.js', line: 17, column: 43 Frame: function:'ViewBase._setupUI', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 492, column: 35 Frame: function:'', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 534, column: 19 Frame: function:'LayoutBaseCommon.eachChildView', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js', line: 125, column: 26 Frame: function:'ViewCommon.eachChild', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 868, column: 14 Frame: function:'ViewBase._setupUI', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 533, column: 14 Frame: function:'', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 534, column: 19 Frame: function:'ContentView.eachChildView', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/content-view/content-view.js', line: 70, column: 13 Frame: function:'ViewCommon.eachChild', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 868, column: 14 Frame: function:'ViewBase._setupUI', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 533, column: 14 Frame: function:'', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 534, column: 19 Frame: function:'ContentView.eachChildView', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/content-view/content-view.js', line: 70, column: 13 Frame: function:'PageBase.eachChildView', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/page/page-common.js', line: 120, column: 40 Frame: function:'ViewCommon.eachChild', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 868, column: 14 Frame: function:'ViewBase._setupUI', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 533, column: 14 Frame: function:'ViewBase._addViewCore', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 431, column: 18 Frame: function:'ViewBase._addView', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 420, column: 14 Frame: function:'FragmentCallbacksImplementation.onCreateView', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 588, column: 24 Frame: function:'FragmentClass.onCreateView', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/ui/frame/fragment.js', line: 27, column: 38

at com.tns.Runtime.callJSMethodNative(Native Method) at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101) at com.tns.Runtime.callJSMethodImpl(Runtime.java:983) at com.tns.Runtime.callJSMethod(Runtime.java:970) at com.tns.Runtime.callJSMethod(Runtime.java:954) at com.tns.Runtime.callJSMethod(Runtime.java:946) at com.tns.FragmentClass.onCreateView(FragmentClass.java:45) at android.app.Fragment.performCreateView(Fragment.java:2059) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:899) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1076) at android.app.BackStackRecord.run(BackStackRecord.java:833) at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1461) at android.app.FragmentManagerImpl$1.run(FragmentManager.java:448) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5538) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bradmartin/nativescript-drawingpad/issues/42#issuecomment-400348496, or mute the thread https://github.com/notifications/unsubscribe-auth/AFulhJ98F3plrxW5gSwW9HB2k4c68_Gbks5uAlDQgaJpZM4U29rN .

rigoparis commented 6 years ago

Sure thing, I'll go ahead and create a repo.

I'll post it here as soon as I have it

rigoparis commented 6 years ago

@bradmartin Hey man,

Here's the repo: https://github.com/rigoparis/-N--VueDrawingPadExample

I did this on a clean project and the same first error occurred

KinsleySen commented 5 years ago

@rigoparis hey, mine works here's my method to get the image

getDraw(args) { const pad = this.$refs.DrawingPad.nativeView; pad.getDrawing().then( data => { console.log(data); }, err => { console.log(err); } ); },

scottpal commented 4 years ago

@rigoparis hey, mine works here's my method to get the image

getDraw(args) { const pad = this.$refs.DrawingPad.nativeView; pad.getDrawing().then( data => { console.log(data); }, err => { console.log(err); } ); },

Would you be willing to post your own repo? I'm relatively new to NS and am trying to get this to work using VS-Vue, but all the examples I can find use Angular. It would be very helpful