NativeScript / canvas

Apache License 2.0
88 stars 18 forks source link

Path2 constructor doesn't work in Android #21

Closed darkyelox closed 3 years ago

darkyelox commented 3 years ago

There is an error in when I try to use Path2D in Android, it throws:

JS: ERROR Error: Uncaught (in promise): Error: java.lang.UnsatisfiedLinkError: No implementation found for long com.github.triniwiz.canvas.TNSPath2D.nativeCreateWithString(java.lang.String) (tried Java_com_github_triniwiz_canvas_TNSPath2D_nativeCreateWithString and Java_com_github_triniwiz_canvas_TNSPath2D_nativeCreateWithString__Ljava_lang_String_2)
JS: Path2D(file: node_modules/@nativescript/canvas/Canvas2D/Path2D/Path2D.android.js:6:0)

It happens when I try to use it with:

private wavePath = new Path2D('m 529.60955,97.99314 c 0.6063,-1.333289 1.37676,-3.807172 1.98742,-5.736518 1.43782,-4.542735 2.3486,-9.24988 3.94428,-13.739595 1.22843,-3.456349 2.1906,-7.134241 4.31994,-10.121089 2.50635,-3.515675 5.39013,-7.750928 9.60411,-8.691194 3.50651,-0.782406 7.08821,1.554836 10.30798,3.148839 2.05932,1.019506 3.67272,2.768704 5.59886,4.021772 2.77486,1.805203 5.49277,3.794271 8.56554,5.025813 3.86089,1.547416 7.99792,2.541823 12.1447,2.866163 5.35707,0.419004 10.80774,-0.151465 16.0742,-1.218311 3.78969,-0.767692 7.37664,-2.333646 10.99612,-3.693975 2.07082,-0.778288 3.94835,-2.163077 6.1259,-2.553359 2.18054,-0.390818 4.58096,-0.548775 6.64047,0.267237 1.54229,0.611079 2.85859,1.86767 3.76038,3.260092 2.96224,4.573869 3.08537,10.453394 4.72009,15.651745 1.96892,6.26112 3.2268,12.824907 6.12763,18.71247 2.07408,4.20957 4.22612,8.75648 7.93915,11.62625 2.96238,2.28961 6.83183,3.94093 10.57291,3.7915 3.38524,-0.13522 6.91738,-1.73851 9.26315,-4.183 6.08045,-6.33638 6.87768,-16.17172 9.84421,-24.437391 1.74002,-4.848251 1.96996,-10.340419 4.6583,-14.734284 1.81524,-2.966851 3.97766,-6.878408 7.42637,-7.32971 2.82851,-0.370141 5.36921,2.272137 7.43261,4.241871 3.26721,3.118901 3.77533,8.565327 7.25572,11.444398 2.55835,2.116335 6.02236,2.939886 9.26309,3.662177 7.03313,1.567536 14.37402,1.093223 21.57544,1.341481 13.90882,0.479484 22.43939,0.306472 41.75025,0.284877 M 336.35167,63.253613 c 0.4411,-0.480066 2.6942,-4.737301 3.69252,-7.263121 1.38582,-3.506239 2.03102,-7.262789 3.15246,-10.862316 0.81118,-2.603683 1.50765,-5.257031 2.58585,-7.761959 1.10053,-2.556813 1.89254,-5.477095 3.94002,-7.36291 1.54183,-1.42009 3.68274,-2.702045 5.76933,-2.50197 1.83387,0.175843 3.38948,1.700041 4.56032,3.122407 1.67506,2.0349 2.34755,4.744226 3.12997,7.261062 0.83847,2.697134 1.20783,5.521593 1.64858,8.31145 0.48039,3.040814 0.71359,6.11558 1.08328,9.171828 0.48534,4.012315 0.85663,8.041159 1.48989,12.032802 1.02788,6.479093 2.38773,12.902586 3.74537,19.320687 0.97041,4.58754 1.97728,9.169751 3.14452,13.711197 1.54768,6.02166 3.02249,12.08229 5.11351,17.93749 1.22331,3.42546 2.63743,6.79686 4.33265,10.01501 0.62418,1.18492 1.11098,2.5426 2.13883,3.40118 1.02188,0.85359 2.38531,1.65984 3.70598,1.49045 1.64091,-0.21047 2.93409,-1.67896 3.98819,-2.954 1.05816,-1.27994 1.57901,-2.9338 2.15973,-4.48967 1.04059,-2.78799 1.56485,-5.74232 2.34762,-8.61338 0.86232,-3.16279 1.84575,-6.295 2.58772,-9.48817 1.03846,-4.46918 1.75302,-9.007538 2.6045,-13.516081 0.97933,-5.185468 1.9794,-10.367519 2.88037,-15.567174 1.58134,-9.126174 2.66075,-18.339531 4.43192,-27.43077 0.96129,-4.934193 1.76093,-9.9359 3.35935,-14.701965 0.76401,-2.278066 1.49693,-4.665267 2.95594,-6.57435 1.03208,-1.350466 2.24329,-3.363364 3.93841,-3.238753 2.66618,0.195994 4.10523,3.596977 5.38305,5.945191 1.2209,2.243587 1.51277,4.891678 1.9766,7.403475 0.75269,4.076094 0.81811,8.249922 1.29474,12.367434 1.07304,9.269735 1.72725,18.615122 3.523,27.772343 0.81198,4.140616 1.85281,8.25423 3.26782,12.229373 0.61514,1.728087 1.40802,3.392846 2.25818,5.018242 0.69141,1.321881 1.30717,2.727075 2.3047,3.836285 1.23148,1.36935 2.71732,2.60127 4.40868,3.32996 1.98171,0.85378 4.22826,1.17543 6.38369,1.07415 2.09018,-0.0982 4.2056,-0.65869 6.06549,-1.6175 1.67083,-0.86135 3.04486,-2.23739 4.34443,-3.59559 0.82902,-0.866414 1.50439,-1.871865 2.16922,-2.869831 1.32172,-1.983999 2.66551,-3.98597 3.60374,-6.177524 1.43963,-3.362723 2.01783,-7.032101 3.04229,-10.543639 0.81117,-2.780403 1.42306,-5.628936 2.4581,-8.333992 0.92578,-2.419523 1.39347,-5.307294 3.3389,-7.017992 1.09564,-0.963445 2.71155,-1.530767 4.16046,-1.359573 1.57989,0.186669 2.98807,1.329012 4.06614,2.498906 1.48338,1.609721 2.08218,3.856042 2.97063,5.856611 1.22605,2.760774 2.17463,5.636632 3.24711,8.46061 1.18281,3.114484 2.19355,6.29788 3.51567,9.355828 1.01114,2.338671 2.26716,4.563833 3.37092,6.860241 0.92959,1.934036 1.72136,3.936535 2.73834,5.826085 0.94371,1.75343 1.95519,3.47849 3.11285,5.09866 1.18913,1.66421 2.21611,3.58839 3.91868,4.72191 1.90349,1.26728 4.27744,2.13398 6.56058,2.00553 2.90255,-0.1633 5.72084,-1.66663 8.0018,-3.46903 1.45788,-1.15202 2.36695,-2.87998 3.33968,-4.46313 0.6996,-1.13862 1.22966,-2.37461 1.77813,-3.59326 0.78706,-1.74877 1.38197,-3.555127 2.16755,-5.32922 m -450.234701,5.59531 c 1.164518,-1.36948 2.009543,-4.527868 3.071482,-6.76526 0.977074,-2.058591 1.785392,-4.220027 3.035578,-6.125153 1.312243,-1.999693 2.596626,-4.222347 4.62999,-5.481786 2.242815,-1.38917 5.075752,-2.245435 7.688329,-1.878755 2.122491,0.297894 3.959822,1.788995 5.584602,3.186781 1.64162,1.412271 2.92144,3.235927 4.02643,5.098291 1.53831,2.592675 2.55078,5.474474 3.54303,8.321192 1.31733,3.77936 2.4011,6.71809 3.39338,8.85251 1.32696,2.85431 2.49029,5.7442 3.82977,8.49417 0.94515,1.94041 1.97799,3.81116 3.21789,5.55059 1.91116,2.46526 4.78163,5.03939 7.95328,5.26771 1.59297,0.11468 3.06283,-1.07722 4.33233,-2.04628 1.47516,-1.12605 2.5156,-2.73838 3.621,-4.22908 0.78022,-1.05219 1.4461,-2.18581 2.11405,-3.31261 1.09694,-1.85049 2.21709,-3.69799 3.10626,-5.6568 1.83601,-4.04464 3.21845,-8.28617 4.57026,-12.51732 0.99729,-3.121515 1.56806,-6.371004 2.60707,-9.478877 1.88343,-5.633658 3.26833,-12.202956 6.55811,-16.569848 1.86546,-2.476232 4.59367,-5.047532 7.68833,-5.234 2.88241,-0.173679 5.84196,1.764897 7.69458,3.979906 3.70664,4.431704 4.54825,10.81069 5.11591,16.560212 0.8709,8.820905 1.26843,14.397657 2.68481,21.469427 1.78896,8.93205 3.14694,18.23091 7.31391,26.33142 1.93033,3.75253 3.7338,9.78872 7.95328,9.8496 4.34406,0.0627 6.3134,-6.13266 8.47725,-9.89995 2.09446,-3.64649 2.94629,-7.88457 4.14282,-11.91594 1.50599,-5.07397 2.78799,-10.22112 3.81208,-15.41385 0.85443,-4.33248 1.39301,-8.72304 1.9402,-13.104938 0.67382,-5.395885 1.07726,-10.822187 1.65267,-16.229451 0.597,-5.610215 1.24357,-11.215045 1.86729,-16.822353 0.56559,-5.084749 0.96013,-10.191569 1.70027,-15.253856 0.5433,-3.715938 0.92346,-7.490733 2.00981,-11.085619 0.79093,-2.617277 1.23503,-5.683998 3.25143,-7.530572 1.79751,-1.646118 4.53274,-2.670202 6.94154,-2.298182 2.20335,0.340289 3.9325,2.258581 5.41944,3.919775 1.98191,2.214171 3.15847,5.054019 4.39545,7.755947 1.41536,3.091578 2.25318,6.416519 3.4313,9.606058 0.69045,1.869247 1.32522,3.76287 2.13152,5.585152 0.72199,1.631756 1.46833,3.265107 2.41744,4.776104 0.72614,1.156031 1.54455,2.2666 2.48877,3.252574 0.78447,0.819163 1.67037,1.547928 2.61035,2.182643 1.00294,0.677229 2.03424,1.391543 3.20089,1.713215 1.52045,0.419222 3.15558,0.361847 4.72643,0.220609 2.09313,-0.188198 4.25654,-0.489324 6.1444,-1.412662 1.69863,-0.830787 3.06096,-2.245971 4.39744,-3.583641 0.97992,-0.980792 1.35004,-1.803665 2.62462,-3.226571 0.47807,-0.519754 1.89572,-2.910413 2.69709,-4.448114 1.08425,-2.080497 1.87951,-4.29937 2.84264,-6.43863 1.74537,-3.876712 2.11785,-6.878947 4.27271,-10.543882 1.23064,-2.093038 3.44847,-5.418733 5.35533,-6.921789 1.60411,-1.26442 3.60873,-2.400477 5.65102,-2.36925 1.96064,0.02998 3.87475,1.151027 5.35303,2.439326 2.12166,1.848995 3.51132,4.358159 4.78026,6.870135 1.70769,3.380535 2.73345,7.234449 3.8555,10.851802 0.96193,3.101155 1.09094,6.441153 2.22755,9.482633 0.73372,1.963378 1.73971,3.838227 2.92895,5.564171 0.76007,1.103081 1.58722,2.208506 2.65631,3.015681 0.9673,0.730322 2.15058,1.130743 3.28241,1.564309 0.64978,0.248909 1.31722,0.468065 2.00214,0.590743 1.20559,0.215936 2.44118,0.252484 3.66595,0.248014 1.25401,-0.0046 2.51998,-0.04487 3.75153,-0.281185 0.82318,-0.157955 1.68135,-0.320511 2.39901,-0.753541 1.66374,-1.003882 4.1382,-4.105792 4.1382,-4.105792 0,0 -1.02543,1.146129 0,0 M 6.5284134,107.41105 c 0,0 5.0359116,-0.64841 7.0970996,-2.73752 2.152985,-2.18215 3.217302,-5.221537 4.944598,-7.754041 1.428459,-2.094359 2.479108,-4.58776 4.477518,-6.147628 2.044767,-1.596051 4.620451,-2.92026 7.214375,-2.916996 2.562832,0.0032 5.135503,1.279033 7.120623,2.899964 1.726218,1.409527 2.57939,3.641534 3.708891,5.562684 0.976069,1.660181 1.670777,3.475075 2.641977,5.138107 1.489563,2.55066 2.952971,5.15637 4.872438,7.40142 1.690781,1.97758 3.488778,4.00796 5.773373,5.25302 2.672206,1.45631 5.786303,2.53509 8.823614,2.34467 3.479654,-0.21815 6.859016,-1.89827 9.694009,-3.92765 1.845268,-1.3209 3.169338,-3.27809 4.454142,-5.14868 0.810839,-1.18052 1.547876,-2.67076 2.023898,-3.78995')

Seems like Android doesn't have the code for SVG logic

triniwiz commented 3 years ago

Thanks

triniwiz commented 3 years ago

@darkyelox can you try java.lang.System.loadLibrary("canvasnative") it will force the native lib to be loaded earlier