1

Tengo un arreglo de esta forma:

ImageView img0;

        int [] f1={R.drawable.ic_butterfly, R.drawable.ic_butterfly, R.drawable.ic_butterfly, R.drawable.ic_butterfly};
    Random r1=new Random();
    int a1=r1.nextInt(4);
    img0.setImageResource(f1[a1]);

he importado butterfly.svg y generó un xml de nombre ic_butterfly dentro de res/drawable, en el logcat arroja

Caused by: android.content.res.Resources$NotFoundException: File >res/drawable-anydpi-v21/ic_butterfly.xml from drawable resource ID >#0x7f060076

Caused by: android.content.res.Resources$NotFoundException: File >res/drawable-anydpi-v21/$ic_butterfly__0.xml from color state list resource >ID #0x7f060000

Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line 0: invalid drawable tag gradient

código ic_butterfly.xml:

<vector android:height="24dp" android:viewportHeight="300.81"
    android:viewportWidth="569.16" android:width="24dp"
    xmlns:aapt="http://schemas.android.com/aapt" xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:pathData="M126.58,194.33c-0.77,18.1 1.85,24.19 10.95,31.37s14,16.52 23.47,19.42 22.51,10 26.27,17.17 17.71,15.71 25.94,11.38 3.22,-21.34 25.16,-17.3 16.29,-11 19.55,-15.75 40.47,-145.26 40.47,-145.26S141.22,174.49 126.58,194.33Z"/>
    <path android:pathData="M172.31,209.46c3.8,8.9 18.38,18.7 25.41,15.43s9.31,-37.56 13,-41.78S171.35,207.21 172.31,209.46Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="149053.22383238704"
                android:endY="36004.009928779866"
                android:startX="124785.89751461674"
                android:startY="45270.800555939924" android:type="linear">
                <item android:color="#FFFBB03B" android:offset="0.0"/>
                <item android:color="#FFED1C24" android:offset="1.0"/>
            </gradient>
        </aapt:attr>
    </path>
    <path android:pathData="M216.33,186.14c-6.48,17.41 -11.3,41.57 -12.39,44.94s8.81,9.94 10.82,9.76 7.64,-3.21 9.63,-5.75 10.31,-55.05 15.1,-63.41S217.33,183.47 216.33,186.14Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="10712.313098068236"
                android:endY="23186.20463623047"
                android:startX="8394.30330039978"
                android:startY="23186.20463623047" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M230.19,233.08c5.37,-7.67 14.74,-65 15.78,-69.2s29.44,-39 32.54,-40.22 -34.18,113.28 -36,123.16S227.18,237.41 230.19,233.08Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="16901.09370414734"
                android:endY="39227.791661376956"
                android:startX="12229.364813461303"
                android:startY="39227.791661376956" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:fillColor="#fff" android:pathData="M139.2,217.08a5.25,3.56 69.1,1 0,6.65 -2.54a5.25,3.56 69.1,1 0,-6.65 2.54z"/>
    <path android:fillColor="#fff" android:pathData="M151.93,227.73a4.02,3.04 69.11,1 0,5.68 -2.17a4.02,3.04 69.11,1 0,-5.68 2.17z"/>
    <path android:fillColor="#fff" android:pathData="M166.67,239.72a4.14,3.88 69.1,1 0,7.25 -2.77a4.14,3.88 69.1,1 0,-7.25 2.77z"/>
    <path android:fillColor="#fff" android:pathData="M170.17,227a3.97,3.45 69.1,1 0,6.45 -2.46a3.97,3.45 69.1,1 0,-6.45 2.46z"/>
    <path android:fillColor="#fff" android:pathData="M182.99,246.79a5.97,3.31 69.1,1 0,6.18 -2.36a5.97,3.31 69.1,1 0,-6.18 2.36z"/>
    <path android:fillColor="#fff" android:pathData="M194.73,260.62a6.05,5.05 69.1,1 0,9.44 -3.6a6.05,5.05 69.1,1 0,-9.44 3.6z"/>
    <path android:fillColor="#fff" android:pathData="M198.61,244.94a4.14,3.44 69.09,1 0,6.43 -2.46a4.14,3.44 69.09,1 0,-6.43 2.46z"/>
    <path android:fillColor="#fff" android:pathData="M188.15,234.16a3.97,3.4 69.09,1 0,6.35 -2.43a3.97,3.4 69.09,1 0,-6.35 2.43z"/>
    <path android:fillColor="#fff" android:pathData="M213.66,253.37a3.31,3.59 69.09,1 0,6.71 -2.56a3.31,3.59 69.09,1 0,-6.71 2.56z"/>
    <path android:fillColor="#fff" android:pathData="M227.06,250.04a4.4,4.49 69.11,1 0,8.39 -3.2a4.4,4.49 69.11,1 0,-8.39 3.2z"/>
    <path android:pathData="M246.74,252.59c0.16,-8.57 3,-20.67 5.22,-27.72s27.12,-92.56 28.72,-95.83S263.29,230.41 250.27,251.23C248.03,254.84 246.71,254.22 246.74,252.59Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="11140.952912979124"
                android:endY="38507.4492791748"
                android:startX="8435.857337265015"
                android:startY="38507.4492791748" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M270.06,79.88C194.19,49.68 110.33,53.41 57,65.46s-66,34.67 -51.33,54.49 25.52,28.1 48.31,33.59 45.28,24.1 57.2,29S146.58,221.06 172.9,211.01 211.98,172.41 234.34,159.75s28.52,-19.76 33.82,-30.66 10.51,-15.84 15.1,-14.64 3.68,-32.16 -0.15,-36S278.71,83.32 270.06,79.88Z"/>
    <path android:pathData="M175.1,103.73c-12.28,11.2 -40.88,29.22 -50,36.25s13.35,25.65 25.38,16.92S203.58,108.55 203.37,103.41 175.1,103.73 175.1,103.73Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="21440.793780593875"
                android:endY="13787.792133331299"
                android:startX="13541.902606124877"
                android:startY="13787.792133331299" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M217.33,105.93c-11.45,10.28 -58.63,55.51 -65.9,61.24s8.11,25.88 20.86,17.46S270.58,104.51 283.35,96.09s-64,9.05 -64,9.05">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="49176.88120552063"
                android:endY="24261.894482269287"
                android:startX="25721.849458847046"
                android:startY="24261.894482269287" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M276.9,86.94c-22.37,-6.63 -71.23,-16.18 -103.84,-10.22s-42.72,-0.36 -22.34,15S276.28,92.31 278.58,91.41 283,88.75 276.9,86.94Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="49121.83437187195"
                android:endY="6489.278750610351"
                android:startX="29431.74709953308"
                android:startY="6489.278750610351" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M140.9,97.28c-13.63,-0.21 -37,19.66 -36.15,24.06s12.6,16.48 18,15.19S164.52,104.41 164.52,104.41 146.85,97.41 140.9,97.28Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="12630.153940505981"
                android:endY="7323.636122360229"
                android:startX="8876.562898025513"
                android:startY="7323.636122360229" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M83.11,75C69.5,79.61 39.58,88.07 38.39,100.41S49.58,104.95 49.58,104.95s29.08,-21.59 39.68,-23.94C87.51,75.69 83.11,75 83.11,75Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="7569.439549026489"
                android:endY="4945.0285181427"
                android:startX="4668.6560599517825"
                android:startY="4945.0285181427" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M85.19,86.63c-13.81,5.54 -39.16,25.9 -37.07,29.89s5.22,5.93 9.86,4.15 34.13,-23.67 36.58,-25.87S91.79,83.98 85.19,86.63Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="7494.592852516174"
                android:endY="5620.6397597503665"
                android:startX="4814.064075431824"
                android:startY="5620.6397597503665" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M69.39,125.78c6.46,-14.44 29.16,-27.1 35.08,-28.77s-1,9.28 -3.67,14.12S74.68,134.99 73.14,135.58 63.97,137.9 69.39,125.78Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="7258.968316726685"
                android:endY="6999.219652175903"
                android:startX="4961.642607345581"
                android:startY="6999.219652175903" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:fillColor="#fff" android:pathData="M28.9,89.6a5,8.31 69.1,1 0,15.53 -5.93a5,8.31 69.1,1 0,-15.53 5.93z"/>
    <path android:fillColor="#fff" android:pathData="M38.84,77.72a3.31,5.52 69.09,1 0,10.31 -3.94a3.31,5.52 69.09,1 0,-10.31 3.94z"/>
    <path android:fillColor="#fff" android:pathData="M18.85,107.04a4.6,8.84 69.1,1 0,16.52 -6.31a4.6,8.84 69.1,1 0,-16.52 6.31z"/>
    <path android:fillColor="#fff" android:pathData="M33.67,125.42a4.24,8.31 69.1,1 0,15.53 -5.93a4.24,8.31 69.1,1 0,-15.53 5.93z"/>
    <path android:fillColor="#fff" android:pathData="M48.55,135.7a4.05,7.37 69.09,1 0,13.77 -5.26a4.05,7.37 69.09,1 0,-13.77 5.26z"/>
    <path android:fillColor="#fff" android:pathData="M80.93,139.69a5.25,9.11 69.09,1 0,17.02 -6.5a5.25,9.11 69.09,1 0,-17.02 6.5z"/>
    <path android:fillColor="#fff" android:pathData="M99.34,147.75a3.04,8.84 69.1,1 0,16.52 -6.31a3.04,8.84 69.1,1 0,-16.52 6.31z"/>
    <path android:fillColor="#fff" android:pathData="M106.62,162.11a3.04,7.21 69.09,1 0,13.47 -5.15a3.04,7.21 69.09,1 0,-13.47 5.15z"/>
    <path android:pathData="M96.9,88.26a7.55,8.38 69.1,1 0,15.66 -5.98a7.55,8.38 69.1,1 0,-15.66 5.98z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="3402.86078911629"
                android:endY="1112.6840175597988"
                android:startX="3138.3880319007008"
                android:startY="1213.676340966681" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M118.28,93.09a4.24,8.22 69.09,1 0,15.36 -5.87a4.24,8.22 69.09,1 0,-15.36 5.87z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="3323.4605265966893"
                android:endY="439.13315650599543"
                android:startX="3077.5718788809236"
                android:startY="533.0780767110572" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M127.27,75.62a4.66,7.1 69.1,1 0,13.27 -5.07a4.66,7.1 69.1,1 0,-13.27 5.07z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="3106.846001866653"
                android:endY="402.10880503499175"
                android:startX="2921.3467881435104"
                android:startY="472.944065276101" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:fillColor="#fff" android:pathData="M15.64,118.24a2.82,4.24 69.1,1 0,7.92 -3.03a2.82,4.24 69.1,1 0,-7.92 3.03z"/>
    <path android:fillColor="#fff" android:pathData="M8.44,106.09a2.39,4.05 69.1,1 0,7.57 -2.89a2.39,4.05 69.1,1 0,-7.57 2.89z"/>
    <path android:fillColor="#fff" android:pathData="M6.34,97.42a2.03,5.52 69.09,1 0,10.31 -3.94a2.03,5.52 69.09,1 0,-10.31 3.94z"/>
    <path android:fillColor="#fff" android:pathData="M26.15,134.16a2.62,5.66 69.1,1 0,10.58 -4.04a2.62,5.66 69.1,1 0,-10.58 4.04z"/>
    <path android:fillColor="#fff" android:pathData="M36.98,139.19a2.35,4.28 69.1,1 0,8 -3.05a2.35,4.28 69.1,1 0,-8 3.05z"/>
    <path android:fillColor="#fff" android:pathData="M48.19,146.58a2.35,4.83 69.1,1 0,9.02 -3.45a2.35,4.83 69.1,1 0,-9.02 3.45z"/>
    <path android:fillColor="#fff" android:pathData="M59.84,146.87a2.49,4.56 69.1,1 0,8.52 -3.25a2.49,4.56 69.1,1 0,-8.52 3.25z"/>
    <path android:fillColor="#fff" android:pathData="M76.93,154.07a3.47,6.08 69.1,1 0,11.36 -4.34a3.47,6.08 69.1,1 0,-11.36 4.34z"/>
    <path android:fillColor="#fff" android:pathData="M92.77,159.71a2.49,6.04 69.09,1 0,11.28 -4.31a2.49,6.04 69.09,1 0,-11.28 4.31z"/>
    <path android:fillColor="#fff" android:pathData="M104.51,174.15a4.42,6.25 69.1,1 0,11.68 -4.46a4.42,6.25 69.1,1 0,-11.68 4.46z"/>
    <path android:fillColor="#fff" android:pathData="M122.05,181.35a3.59,5.21 69.09,1 0,9.73 -3.72a3.59,5.21 69.09,1 0,-9.73 3.72z"/>
    <path android:fillColor="#fff" android:pathData="M131.33,171.9a3.73,5.39 69.1,1 0,10.07 -3.85a3.73,5.39 69.1,1 0,-10.07 3.85z"/>
    <path android:fillColor="#fff" android:pathData="M136.17,191.93a3.45,4.97 69.1,1 0,9.29 -3.55a3.45,4.97 69.1,1 0,-9.29 3.55z"/>
    <path android:fillColor="#fff" android:pathData="M152.25,201.45a3.73,5.52 69.1,1 0,10.31 -3.94a3.73,5.52 69.1,1 0,-10.31 3.94z"/>
    <path android:fillColor="#fff" android:pathData="M88.86,75.06a3.59,5.8 69.09,1 0,10.84 -4.14a3.59,5.8 69.09,1 0,-10.84 4.14z"/>
    <path android:fillColor="#fff" android:pathData="M103.41,66.48a2.83,5.1 69.09,1 0,9.53 -3.64a2.83,5.1 69.09,1 0,-9.53 3.64z"/>
    <path android:fillColor="#fff" android:pathData="M139.96,64.12a3.22,4.97 69.1,1 0,9.29 -3.55a3.22,4.97 69.1,1 0,-9.29 3.55z"/>
    <path android:fillColor="#fff" android:pathData="M173.49,67.9a3.36,5.73 69.1,1 0,10.71 -4.09a3.36,5.73 69.1,1 0,-10.71 4.09z"/>
    <path android:pathData="M412.28,267.68c-8.12,16.19 -13.38,20.24 -24.81,22.09s-20.3,7.61 -30,5.55 -24.55,-2.18 -31.31,2.22 -23.11,5.12 -28.2,-2.67 7.56,-20.21 -13.58,-27.35 -8.91,-17.49 -9.43,-23.26 35.26,-146.61 35.26,-146.61S409.17,243.26 412.28,267.68Z"/>
    <path android:pathData="M364.99,258.69c-7.65,5.93 -25.16,7.41 -29.7,1.13s10.12,-37.34 8.94,-42.84S366.92,257.2 364.99,258.69Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="-23829.69236360679"
                android:endY="14347.815809669704"
                android:startX="-22772.94838332061"
                android:startY="15619.210907875986" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M337.87,216.91c-2.8,18.37 -10.34,41.82 -11,45.3s-12.54,4.4 -14.2,3.27 -5.12,-6.52 -5.62,-9.71 17.76,-53.12 17.63,-62.75S338.29,214.1 337.87,216.91Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="-35958.96457777922"
                android:endY="23870.056880797598"
                android:startX="-34822.417940097075"
                android:startY="25237.46455095114" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M302.93,251.19c-1,-9.31 18.71,-63.93 19.86,-68.14s-6.74,-48.43 -8.87,-51 -25.22,115.61 -28.39,125.15S303.47,256.41 302.93,251.19Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="-59348.73428439401"
                android:endY="38492.31322289459"
                android:startX="-57064.69410068067"
                android:startY="41240.299062277285" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:fillColor="#fff" android:pathData="M383.9,282.09a3.56,5.25 50,1 0,8.04 -6.75a3.56,5.25 50,1 0,-8.04 6.75z"/>
    <path android:fillColor="#fff" android:pathData="M368.89,284.76a3.04,4.01 49.99,1 0,6.14 -5.16a3.04,4.01 49.99,1 0,-6.14 5.16z"/>
    <path android:fillColor="#fff" android:pathData="M350.21,281.89a3.89,3.89 0,1 0,5.67 0.31A4,4 0,0 0,350.21 281.89Z"/>
    <path android:fillColor="#fff" android:pathData="M353.08,275.01a3.45,3.97 50.01,1 0,6.08 -5.1a3.45,3.97 50.01,1 0,-6.08 5.1z"/>
    <path android:fillColor="#fff" android:pathData="M330.79,287.39a3.32,5.97 49.99,1 0,9.15 -7.68a3.32,5.97 49.99,1 0,-9.15 7.68z"/>
    <path android:fillColor="#fff" android:pathData="M312.64,292.54a5.05,6.05 49.99,1 0,9.27 -7.78a5.05,6.05 49.99,1 0,-9.27 7.78z"/>
    <path android:fillColor="#fff" android:pathData="M319.39,276.9a3.44,4.14 49.99,1 0,6.34 -5.32a3.44,4.14 49.99,1 0,-6.34 5.32z"/>
    <path android:fillColor="#fff" android:pathData="M333.91,272.49a3.4,3.97 50.01,1 0,6.08 -5.1a3.4,3.97 50.01,1 0,-6.08 5.1z"/>
    <path android:fillColor="#fff" android:pathData="M302.66,276.39a3.59,3.31 50,1 0,5.07 -4.26a3.59,3.31 50,1 0,-5.07 4.26z"/>
    <path android:fillColor="#fff" android:pathData="M291.16,266.91a4.49,4.4 49.99,1 0,6.74 -5.66a4.49,4.4 49.98,1 0,-6.74 5.66z"/>
    <path android:pathData="M278.99,260.19c4,-7.56 7.41,-19.53 8.92,-26.76s21.3,-94.06 21.5,-97.7 -34.09,97 -32.85,121.56C276.77,261.53 278.22,261.64 278.99,260.19Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="-55928.14827754169"
                android:endY="37637.849972836644"
                android:startX="-54259.40447499727"
                android:startY="39645.55735541622" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M342.58,97.93c81,10.5 152.46,54.5 193.19,91S576.58,251.32 554.13,261.51s-36,12.15 -58.54,5.86 -51.28,-1 -64.09,-2.47 -49.67,16.44 -67.78,-5.14 -15.39,-52.71 -28.76,-74.66 -15.31,-31.14 -14.65,-43.24 -1.48,-19 -6.08,-20.14 12.42,-29.89 17.65,-31.39S333.35,96.73 342.58,97.93Z"/>
    <path android:pathData="M413.97,164.95c5.29,15.76 21.52,45.41 26.08,56s-24.14,15.92 -30.41,2.44 -22.88,-68.06 -20.24,-72.44S413.97,164.95 413.97,164.95Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="-34598.702241146886"
                android:endY="18103.94643493692"
                android:startX="-31260.24788354059"
                android:startY="22120.524324215807" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M376,146.34c5,14.55 24.24,77 27.81,85.56s-19.67,18.67 -26.72,5.11 -46.94,-117.82 -54,-131.37 51.48,39 51.48,39">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="-67848.02823146716"
                android:endY="30050.584265073852"
                android:startX="-58824.10943023778"
                android:startY="40907.48654653988" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M333.17,100.78c21.1,10 70.11,20.5 95.71,41.56s37.51,20.46 12.21,24 -107.61,-60.25 -111.57,-62.49S327.9,98.29 333.17,100.78Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="-41797.1653379003"
                android:endY="-5923.099251174289"
                android:startX="-30109.8514768665"
                android:startY="8138.200203867435" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M446.99,175.94c12,6.44 22.8,35.19 19.89,38.6s-19,8.27 -23.14,4.51 -20.86,-48.36 -20.86,-48.36S441.75,173.13 446.99,175.94Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="-18944.865248259666"
                android:endY="9367.691047330907"
                android:startX="-17085.87934606124"
                android:startY="11604.283455503028" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M508.32,184.57c9.65,10.65 31.66,32.57 26.74,43.9s-12,-1.44 -12,-1.44 -14.92,-33 -23,-40.22C504.14,183.03 508.32,184.57 508.32,184.57Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="-16278.763082910573"
                android:endY="11263.161082059054"
                android:startX="-14854.92910028262"
                android:startY="12976.21133826441" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M500.85,193.72c9.37,11.56 21.28,42.72 17.86,44.14s-7.44,2.64 -10.64,-1.17 -10.09,-32 -19.38,-40.39C492.28,188.66 496.37,188.2 500.85,193.72Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="-15487.338731640528"
                android:endY="10948.144590001408"
                android:startX="-14356.906162376416"
                android:startY="12308.1962716073" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M495.58,235.61c1.38,-15.76 -12.3,-37.86 -16.66,-42.2s-3.61,8.61 -3.66,14.12 11.22,33.55 12.29,34.82S494.46,248.84 495.58,235.61Z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="-18214.657744011314"
                android:endY="13683.401109895207"
                android:startX="-17505.168346588387"
                android:startY="14537.005539104775" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:fillColor="#fff" android:pathData="M539.42,220.56a8.31,5 50,1 0,7.66 -6.43a8.31,5 50,1 0,-7.66 6.43z"/>
    <path android:fillColor="#fff" android:pathData="M539.61,206.41a5.52,3.32 50,1 0,5.09 -4.27a5.52,3.32 50,1 0,-5.09 4.27z"/>
    <path android:fillColor="#fff" android:pathData="M539.68,239.95a8.84,4.6 49.99,1 0,7.05 -5.91a8.84,4.6 49.99,1 0,-7.05 5.91z"/>
    <path android:fillColor="#fff" android:pathData="M518.41,249.07a8.31,4.24 50,1 0,6.5 -5.45a8.31,4.24 50,1 0,-6.5 5.45z"/>
    <path android:fillColor="#fff" android:pathData="M501.17,251.37a7.37,4.05 49.99,1 0,6.2 -5.21a7.37,4.05 49.99,1 0,-6.2 5.21z"/>
    <path android:fillColor="#fff" android:pathData="M468.89,238.53a9.11,5.25 50,1 0,8.04 -6.75a9.11,5.25 50,1 0,-8.04 6.75z"/>
    <path android:fillColor="#fff" android:pathData="M450.75,235.44a8.84,3.04 50,1 0,4.66 -3.91a8.84,3.04 50,1 0,-4.66 3.91z"/>
    <path android:fillColor="#fff" android:pathData="M438.47,245.67a7.21,3.04 49.99,1 0,4.66 -3.91a7.21,3.04 49.99,1 0,-4.66 3.91z"/>
    <path android:pathData="M480.01,190.11a8.38,7.55 50,1 0,11.57 -9.71a8.38,7.55 50,1 0,-11.57 9.71z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="-3130.029128123261"
                android:endY="-4652.796774757551"
                android:startX="-3303.987508677169"
                android:startY="-4445.481249770561" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M461.24,182.41a8.23,4.25 50.27,1 0,6.53 -5.43a8.23,4.25 50.27,1 0,-6.53 5.43z">
        <aapt:attr name="android:fillColor">
            <gradient android:endX="-2706.4789942711864"
                android:endY="-4320.571286349497"
                android:startX="-2844.395499782262"
                android:startY="-4154.640491057873" android:type="linear"/>
        </aapt:attr>
    </path>
    <path android:pathData="M461.3,161.21a7.1,4.66 50,1 0,7.14 -5.99a7.1,4.66 50,1 0,-7.14 5.99z"/>
    <path android:fillColor="#fff" android:pathData="M541.35,253.78a4.23,2.82 50,1 0,4.32 -3.63a4.23,2.82 50,1 0,-4.32 3.63z"/>
    <path android:fillColor="#fff" android:pathData="M554.01,246.45a4.05,2.39 49.99,1 0,3.66 -3.07a4.05,2.39 49.99,1 0,-3.66 3.07z"/>
    <path android:fillColor="#fff" android:pathData="M559.39,238.52a5.52,2.03 49.99,1 0,3.11 -2.61a5.52,2.03 49.99,1 0,-3.11 2.61z"/>
    <path android:fillColor="#fff" android:pathData="M523.68,261.3a5.66,2.62 50,1 0,4.01 -3.37a5.66,2.62 50,1 0,-4.01 3.37z"/>
    <path android:fillColor="#fff" android:pathData="M512.87,261.31a4.28,2.35 50,1 0,3.6 -3.02a4.28,2.35 50,1 0,-3.6 3.02z"/>
    <path android:fillColor="#fff" android:pathData="M499.1,261.9a4.83,2.35 50,1 0,3.6 -3.02a4.83,2.35 50,1 0,-3.6 3.02z"/>
    <path android:fillColor="#fff" android:pathData="M488.86,256.75a4.56,2.49 50,1 0,3.81 -3.2a4.56,2.49 50,1 0,-3.81 3.2z"/>
    <path android:fillColor="#fff" android:pathData="M468.7,254.26a6.08,3.47 50.01,1 0,5.32 -4.46a6.08,3.47 50.01,1 0,-5.32 4.46z"/>
    <path android:fillColor="#fff" android:pathData="M452.91,250.91a6.04,2.49 49.99,1 0,3.81 -3.2a6.04,2.49 49.99,1 0,-3.81 3.2z"/>
    <path android:fillColor="#fff" android:pathData="M434.01,258.87a6.25,4.42 50,1 0,6.77 -5.68a6.25,4.42 50,1 0,-6.77 5.68z"/>
    <path android:fillColor="#fff" android:pathData="M416.49,256.93a5.21,3.59 50.02,1 0,5.5 -4.61a5.21,3.59 50.02,1 0,-5.5 4.61z"/>
    <path android:fillColor="#fff" android:pathData="M412.73,244.01a5.39,3.73 49.99,1 0,5.71 -4.8a5.39,3.73 49.99,1 0,-5.71 4.8z"/>
    <path android:fillColor="#fff" android:pathData="M399.25,259.38a4.97,3.45 50.02,1 0,5.29 -4.43a4.97,3.45 50.02,1 0,-5.29 4.43z"/>
    <path android:fillColor="#fff" android:pathData="M380,259.61a5.52,3.73 50.01,1 0,5.72 -4.79a5.52,3.73 50.01,1 0,-5.72 4.79z"/>
    <path android:fillColor="#fff" android:pathData="M496.78,179.67a5.8,3.59 49.99,1 0,5.5 -4.62a5.8,3.59 49.99,1 0,-5.5 4.62z"/>
    <path android:fillColor="#fff" android:pathData="M489.28,165.22a5.1,2.83 50,1 0,4.34 -3.64a5.1,2.83 50,1 0,-4.34 3.64z"/>
    <path android:fillColor="#fff" android:pathData="M458.27,145.73a4.97,3.22 50,1 0,4.93 -4.14a4.97,3.22 50,1 0,-4.93 4.14z"/>
    <path android:fillColor="#fff" android:pathData="M424.37,129.03a5.73,3.36 50.01,1 0,5.15 -4.32a5.73,3.36 50.01,1 0,-5.15 4.32z"/>
    <path android:pathData="M386.58,13.46c-2.63,-3.71 -7.05,-3.68 -10.69,-3.36 -7.56,1.2 -13.86,5.53 -19.57,9.56 -19.33,15.12 -33.43,30.52 -37.17,34.18 -1.85,-2.41 -5.57,-1.05 -7.45,-0.62 -2.42,0.55 -4.41,-1.53 -6.09,-2.07a2,2 0,0 0,-2 0.94,352 352,0 0,0 -29.29,-38.1c-4.94,-5 -10.46,-10.36 -17.68,-13.07 -3.61,-0.86 -7.89,-2 -11.3,1.15 -2.63,4.06 0.42,8 2.45,10.73a19.55,19.55 0,0 0,8.87 6.1c1.62,0.34 3.76,1.13 5.54,-0.65 1.42,-1.84 0.82,-3.84 0.37,-5.39 -1.17,-3 -3.25,-6.07 -6.77,-6.54 -1.44,0 -3.82,0.31 -4,2.65a5.31,5.31 0,0 0,2.1 3.89c1.36,1.09 2.29,0.45 2.13,0.1 -0.06,-0.57 -0.31,-0.74 -1.09,-1.4 -1.74,-1.4 -2.33,-3.95 0.79,-3.58 2.24,0.17 4.37,2.72 5.33,5.36 1.35,3 -0.21,5.56 -3.82,4.08a18.13,18.13 0,0 1,-8.13 -5.45c-2,-2.43 -4.35,-6.12 -2.8,-8.8 2,-2.24 6.41,-2 9.58,-1 6.78,2.23 12.32,7.43 17.24,12.27 15,16.25 26,32.12 30.33,37.93 -0.73,1 0,2.49 -0.77,3.5 -1.19,1.53 -4,2.14 -5.39,6.79 -1.19,4 0.25,3.75 0.15,6.58s-1.65,1.1 -7.71,8.44 -0.4,8.22 0.85,15.35 -6.1,41.36 -12.38,65.93 -17.89,40.67 -20.63,62.87c-1.26,10.18 1.6,42.21 19.19,10.06s23.15,-70.07 27.29,-91.09c2.2,-11.16 7.6,-24.44 10.58,-33.53 3.42,-10.45 10.87,-11 11.72,-15.78s-3.08,-12.72 -4.68,-15.36 2,-5.23 2.4,-8.72 -2.31,-6.21 -3.93,-8.13 1,-2.72 -0.85,-5.24c3.93,-3.39 18.21,-18.32 37.28,-33.07 5.69,-4 12.05,-8.17 19.13,-9.45 3.27,-0.32 7.75,-0.12 9.46,2.42 1.38,2.76 -1.52,6.16 -4,8.22a18.07,18.07 0,0 1,-9 4.09c-3.81,0.88 -5.06,-1.78 -3.2,-4.59 1.38,-2.46 3.92,-4.63 6.17,-4.43 3.14,0.17 2.14,2.58 0.18,3.67 -1,0.57 -1.16,0.61 -1.32,1.19 -0.21,0.36 0.8,1 2.11,0.27a5.32,5.32 0,0 0,2.73 -3.46c0.2,-2.34 -2.08,-3.1 -3.5,-3.3 -3.53,-0.16 -6.1,2.45 -7.77,5.22 -0.72,1.44 -1.61,3.26 -0.65,5.32 1.36,2.1 3.63,1.75 5.27,1.7a19.55,19.55 0,0 0,9.74 -4.37C384.42,21.11 387.97,17.95 386.58,13.46Z"/>
    <path android:fillColor="#fff" android:pathData="M260.81,239.41a44.48,44.48 0,0 0,5.35 1.77c2.59,0.86 3.6,-1.19 1.45,-2.16s-6.17,-1.83 -7.42,-2.26S258.02,238.28 260.81,239.41Z"/>
    <path android:fillColor="#fff" android:pathData="M259.5,229.73c4.18,2.21 8.76,3.51 12.43,3.29 3.45,-0.21 3.29,-4.13 1.61,-5.17 -1.95,-1.21 -10.08,-4 -13.52,-3.11A2.66,2.66 0,0 0,259.5 229.73Z"/>
    <path android:fillColor="#fff" android:pathData="M262.33,216.41c5.07,-0.06 11.64,1.17 15.54,3.66 3.31,2.11 5.91,-5.56 0.79,-8.14a41.34,41.34 0,0 0,-14.77 -3.81C261.32,208.1 256.58,216.46 262.33,216.41Z"/>
    <path android:fillColor="#fff" android:pathData="M265.71,202.79c5.46,0.48 13.4,2.06 16.27,3.91s5.78,-2.64 2.23,-5.23 -12.86,-5 -16.57,-5.11S260.58,202.34 265.71,202.79Z"/>
    <path android:fillColor="#fff" android:pathData="M271.03,192.3a27.26,27.26 0,0 1,14 4.45c3.24,2.28 4.56,-4.1 1.8,-6.42 -3.65,-3.06 -13.12,-3.89 -15.33,-3.86S264.72,192.14 271.03,192.3Z"/>
    <path android:fillColor="#fff" android:pathData="M314.34,88.59a5.1,4.05 69.1,1 0,7.57 -2.89a5.1,4.05 69.1,1 0,-7.57 2.89z"/>
    <path android:fillColor="#fff" android:pathData="M290.06,83.47a3.5,4.05 69.1,1 0,7.57 -2.89a3.5,4.05 69.1,1 0,-7.57 2.89z"/>
    <path android:fillColor="#fff" android:pathData="M301.01,73.27m-2.23,0.85a2.39,2.39 119.48,1 1,4.47 -1.71a2.39,2.39 114.07,1 1,-4.47 1.71"/>
    <path android:fillColor="#fff" android:pathData="M302.57,66.61a3.31,2.03 69.1,1 0,3.79 -1.45a3.31,2.03 69.1,1 0,-3.79 1.45z"/>
    <path android:fillColor="#fff" android:pathData="M310.13,76.29a2.39,4.05 69.1,1 0,7.57 -2.89a2.39,4.05 69.1,1 0,-7.57 2.89z"/>
    <path android:fillColor="#fff" android:pathData="M313.7,64.12m-2.22,0.86a2.38,2.38 131.87,1 1,4.45 -1.72a2.38,2.38 124.67,1 1,-4.45 1.72"/>
    <path android:fillColor="#fff" android:pathData="M308.79,60.64a1.71,1.66 69.1,1 0,3.1 -1.18a1.71,1.66 69.1,1 0,-3.1 1.18z"/>
    <path android:fillColor="#fff" android:pathData="M304.35,82.06c-4.81,12.18 -15.51,43.6 -9.85,58.51C300.72,131.6 308.58,93.07 304.35,82.06Z"/>
</vector>
1
  • Los comentarios no deben usarse para discusiones extendidas; esta conversación ha sido trasladada a un chat.
    – Jorgesys
    Commented el 17 ene. 2018 a las 21:19

1 respuesta 1

2

Tienes que seleccionar la imagen .svg y convertirla a imagen vectorial, vector asset, ve al folder donde deseas la imagen y crea un nuevo Vector Asset:

introducir la descripción de la imagen aquí

Seleccionas la imagen .svg a convertir

introducir la descripción de la imagen aquí

Te creará un archivo con extensión .xml, y contenido similar a :

<vector android:height="24dp" android:viewportHeight="24.0"
    android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#FFFFFF" android:pathData="M21.71,11.29l-9,-9c-0.39,-0.39 -1.02,-0.39 -1.41,0l-9,9c-0.39,0.39 -0.39,1.02 0,1.41l9,9c0.39,0.39 1.02,0.39 1.41,0l9,-9c0.39,-0.38 0.39,-1.01 0,-1.41zM14,14.5V12h-4v3H8v-4c0,-0.55 0.45,-1 1,-1h5V7.5l3.5,3.5 -3.5,3.5z"/>
</vector>

este puedes usarlo como recurso y cargarlo mediante su id usando setImageResource(), ejemplo:

ImageView imageView = (ImageView)findViewById(R.id.myImageView);
imageView.setImageResource(R.drawable.ic_directions_white_48px);

introducir la descripción de la imagen aquí


Actualización:

El error que obtienes específicamente al cargar esta imagen,

Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line 0: invalid drawable tag gradient

refiere que existen propiedades no soportadas, en este caso tienes que definir como mínimo compileSdkVersion 24 y targetSdkVersion 24

android {
    ...
    compileSdkVersion 24
    buildToolsVersion '26.0.2'      
    ...
    defaultConfig {
        ...
        targetSdkVersion 24
        ...
    }

}

Con esto podrás mostrar el gráfico sin problemas:

introducir la descripción de la imagen aquí

Al ver que el gráfico era una "mariposa", imagine era un dibujo complejo, en realidad ese no es el objetivo de los .svg para uso en un móvil, el procesamiento para generarlo requiere mucho trabajo del procesador.

7
  • Gracias Jorge, he realizado lo me que me has dicho y genera el xml sin ningún problema, pero al agregarlo al arreglo y correr la app me devuelve unfortunately, matgic has stopped
    – Sergio
    Commented el 17 ene. 2018 a las 16:42
  • Actualiza el código en la pregunta Sergio, especificamente que error envia el LogCat
    – Jorgesys
    Commented el 17 ene. 2018 a las 16:57
  • Gracias por tu valioso tiempo Jorge, he actualizado el código y eso es lo que arroja el logcat
    – Sergio
    Commented el 17 ene. 2018 a las 17:17
  • 1
    Exelente respuesta Jorge! Commented el 17 ene. 2018 a las 19:21
  • @BrunoSosaFastTag hey Bruno, gracias!, saludos!
    – Jorgesys
    Commented el 17 ene. 2018 a las 19:28

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.