React-native-svg: width and height must be > 0 (Bug in 4.3.2 in Android)

Created on 12 Nov 2016  ·  2Comments  ·  Source: react-native-svg/react-native-svg

Upgrading to 4.3.2 works perfectly in IOS but I Android it crashes with following error when View is being updated.

In 4.3.0 it works fine

java.lang.IllegalArgumentException: width and height must be > 0
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.graphics.Bitmap.createBitmap(Bitmap.java:829)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.graphics.Bitmap.createBitmap(Bitmap.java:808)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.graphics.Bitmap.createBitmap(Bitmap.java:775)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at com.horcrux.svg.RNSVGTextShadowNode.hitTest(RNSVGTextShadowNode.java:197)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at com.horcrux.svg.RNSVGGroupShadowNode.hitTest(RNSVGGroupShadowNode.java:91)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at com.horcrux.svg.RNSVGVirtualNode.hitTest(RNSVGVirtualNode.java:249)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at com.horcrux.svg.RNSVGSvgViewShadowNode.hitTest(RNSVGSvgViewShadowNode.java:170)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at com.horcrux.svg.RNSVGSvgView.dispatchTouchEvent(RNSVGSvgView.java:68)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2403)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1737)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.app.Activity.dispatchTouchEvent(Activity.java:2765)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2364)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.View.dispatchPointerEvent(View.java:9514)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4230)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4096)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5922)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5896)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5857)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6025)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:5996)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6048)
11-12 09:59:50.378 2190 2190 E AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858

Most helpful comment

Probably you are having this issue because, similarly to a project of mine, you set the width and height of the canvas at run time.
A fast fix can be this:

<Svg style={{ width: (this.state.width || 100), height: (this.state.height || 100) }}>

All 2 comments

Probably you are having this issue because, similarly to a project of mine, you set the width and height of the canvas at run time.
A fast fix can be this:

<Svg style={{ width: (this.state.width || 100), height: (this.state.height || 100) }}>

为什么Android不能像iOS那样动态设置高度?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AdeilsonSuperlogica picture AdeilsonSuperlogica  ·  3Comments

neiker picture neiker  ·  3Comments

dquilter picture dquilter  ·  3Comments

amorenew picture amorenew  ·  3Comments

akshaypilankar picture akshaypilankar  ·  3Comments