icerockdev / moko-resources

Resources access for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev/
Apache License 2.0
1.12k stars 124 forks source link

svg files in commonMain prevents compilation #586

Open MarkRS-UK opened 1 year ago

MarkRS-UK commented 1 year ago

I can successfully build executables (compose 1.5.1 and KMP 1.9.0) with Moko, but when I include an svg file in commonMain images it fails to build an executable. Is there such a thing as a wrong type of svg?

Running the Moko build tasks (common and android) there's no problem (it does give a warning after build is complete for both) but when I try to build an Android executable it complains

Failed to parse resource file <project>/shared/build/generated/moko/androidMain/res/drawable/rightsmall.xml
at com.android.builder.png.VectorDrawableRenderer.getReasonForPreprocessing(VectorDrawableRenderer.java:236)

The Moko build warning is

[org.jetbrains.compose.ComposeMultiplatformBuildService$Inject] WARNING: Usage of the Custom Compose Compiler plugin ('androidx.compose.compiler') 
with non-JVM targets (Kotlin/Native, Kotlin/JS, Kotlin/WASM) is not supported.

The svg file is

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   width="6.5463915mm"
   height="6.5463915mm"
   viewBox="0 0 6.5463915 6.5463915"
   version="1.1"
   id="svg5"
   xml:space="preserve"
   inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
   sodipodi:docname="rightsmall.svg"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
     id="namedview7"
     pagecolor="#ffffff"
     bordercolor="#000000"
     borderopacity="0.25"
     inkscape:showpageshadow="2"
     inkscape:pageopacity="0.0"
     inkscape:pagecheckerboard="0"
     inkscape:deskcolor="#d1d1d1"
     inkscape:document-units="mm"
     showgrid="false"
     inkscape:zoom="2.1946698"
     inkscape:cx="-6.6069165"
     inkscape:cy="-51.488384"
     inkscape:window-width="1920"
     inkscape:window-height="1051"
     inkscape:window-x="0"
     inkscape:window-y="0"
     inkscape:window-maximized="1"
     inkscape:current-layer="layer1" /><defs
     id="defs2" /><g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(-19.913946,-162.10568)"><image
       width="6.5463915"
       height="6.5463915"
       preserveAspectRatio="none"
       style="image-rendering:optimizeQuality"
       xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAIcHpUWHRSYXcgcHJvZmlsZSB0eXBl
IGV4aWYAAHja5ZhbciwrDkX/GUUPIUGIx3B4RvQM7vB7iSyXH8e+0cfH96Ojq+wiiyRBaEtbm3Lr
r39v9y9eoUpyUXNJNaWLV6yxhsZFue7X3forns/7S33c8+/73fNGoEto5f6a1mN8o19fH8jx0d/f
97s8HvOUx0SPGy8Tiq0cuJgPIx8TSbj7/eO7q+G+aOnNdh7/e58pnoM/fo8ZZ0ylU4ILS7xc5zPc
KwlWSJVGm/mkP1jPxbWcz0v0V/+5p+s+ceDz6oP/rvHol1d33BO9bCt98NOj3+vn/jteemuRD8+V
w1uLdF/tevt6579Z9l737lokjmpMj029bMXfjp0dd8p5LPHO/CvX+bwr78IyA8dPttrd1flSfcCb
20c/ffPbr9MOPzAxhhUybQgjyOkrkkMN44AS7e13yA58phSwGiAndIenLf6sW209FiusPD0jg2cy
sHz/dh87vvt+N9HeFubeX+XpK+wKFl+YYcjZJ6MAxO+HT/X417u7uT6+DFgBQT1uLmywXf2eoqt/
jS05OMuljqHxukPe5/mYABextmKMFxC4khf1yV85hOw9fizg07A8SAwdBLw6DRMrQxRJgFOCrc0z
2Z+xQcPdDb0AhEoibYolEGDFqDGRb4UQak5Fo6omzVq0akuSYtKUUk7GUy1LjllzyjmXXHMrUmLR
kkoupdTSKqwGjamrqeZaaq2tsWiLjbka4xsdPXTpsWtPPffSa2+D8Blx6EgjjzLqaDNMmVCAm2nm
WWadbflFKK24dKWVV1l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JvZmls
ZQAAeJx9kT1Iw0AcxV9TpSoVBzuIOgSsThZERRy1CkWoEGqFVh1MLv0QmjQkKS6OgmvBwY/FqoOL
s64OroIg+AHi4uqk6CIl/i8ptIjx4Lgf7+497t4BQq3ENKttDNB020wl4mImuyKGXhFCGJ0YwJDM
LGNWkpLwHV/3CPD1Lsaz/M/9ObrVnMWAgEg8wwzTJl4nntq0Dc77xBFWlFXic+JRky5I/Mh1xeM3
zgWXBZ4ZMdOpOeIIsVhoYaWFWdHUiCeJo6qmU76Q8VjlvMVZK1VY4578heGcvrzEdZqDSGABi5Ag
QkEFGyjBRoxWnRQLKdqP+/j7Xb9ELoVcG2DkmEcZGmTXD/4Hv7u18hPjXlI4DrS/OM7HMBDaBepV
x/k+dpz6CRB8Bq70pr9cA6Y/Sa82tegR0LMNXFw3NWUPuNwB+p4M2ZRdKUhTyOeB9zP6pizQewt0
rXq9NfZx+gCkqavkDXBwCIwUKHvN590drb39e6bR3w9IZHKWUkgbyQAAAAZiS0dEAAAAAAAA+UO7
fwAAAAlwSFlzAAAO+wAADvsBONmRXwAAAAd0SU1FB+MHDAkeDQHT2MkAAAEBSURBVEjH7ZXBSgJR
FIa/TERau52n+EGxlfUACk3kMyYpNIuWZi0MjPMUdze9QBRYm3vh4iJn9AYKntXlh5lvzv+fcwdO
dXQlqS2pv887GlsA58ArsJSU/wsE+AHW/vwg6S45xMzWwAB489L9LqCzirm0gGfg0ku5mc2SQiLQ
AghDMHLOFWVZ7p1JbN0XcA2svPSYZdkwRfCboE/gCngPIEk3yezasK4DfERSy8y+k3TiARfAUyTl
fwFqdyKpDbwA3RC+mRXJMvHTNY8BzrmiyrPNmnvSjywqUl0rwaJFtIjjOou4NRNJDWAJ9CLApO6w
NCt8ROj21symB/s/OdXh1S85GU86U2+g8QAAAABJRU5ErkJggg==
"
       id="image1167"
       x="19.913946"
       y="162.10568" /></g></svg>
Alex009 commented 10 months ago

it's not moko-resources issue - you can see that it's android gradle plugin issue. we convert svg to xml by tools from AGP. so this svg not valid for android i see