Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVG file warning message in Android Studio editor

I'm using Android Studio 2.0 with SVG2VectorDrawable:

Plugin dialog

If I open a svg file for edit from the \RAW resource folder, the file i underlined with the red color and a warning message "element svg must be declared" is shown as below:

enter image description here

What can I do to solve this problem?

I'm using the SVG plugin only for the editor extension that allows the correct viewing of the SVG XML format

This is the svg file content:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Livello_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="9.693px" height="22.8px" viewBox="0 0 9.693 22.8" enable-background="new 0 0 9.693 22.8" xml:space="preserve">
<path fill-rule="evenodd" clip-rule="evenodd" fill="#616161" d="M7.703,14.038c1.248,0.911,1.99,2.36,1.99,3.916
    c0,2.677-2.17,4.847-4.847,4.847C2.17,22.8,0,20.63,0,17.954c0-1.555,0.743-3.006,1.99-3.916V2.856C1.99,1.281,3.271,0,4.846,0
    c1.577,0,2.856,1.279,2.856,2.856C7.702,6.583,7.702,10.311,7.703,14.038L7.703,14.038z M4.769,11.374h1.115V9.616H4.769V8.983
    h1.115V7.225H4.769V6.593h1.115V4.834H4.769V4.202h1.115V2.856c0-0.573-0.464-1.037-1.037-1.037c-0.573,0-1.037,0.468-1.037,1.037
    v11.42c0,0.47-0.223,0.885-0.618,1.142c-0.855,0.559-1.373,1.508-1.373,2.536c0,1.673,1.355,3.028,3.027,3.028
    c1.673,0,3.028-1.355,3.028-3.028c0-1.027-0.517-1.976-1.373-2.536c-0.396-0.258-0.618-0.667-0.618-1.142v-2.27H4.769V11.374
    L4.769,11.374z M4.899,20.528c0.132,0,0.239-0.108,0.239-0.239l0-0.478c0-0.132-0.108-0.239-0.239-0.239
    c-0.666,0-1.207-0.54-1.207-1.206c0-0.131-0.107-0.239-0.239-0.239H2.976c-0.131,0-0.239,0.108-0.239,0.239
    C2.736,19.56,3.705,20.528,4.899,20.528z"/>
</svg>
like image 451
Seraphim's Avatar asked Apr 12 '16 09:04

Seraphim's


1 Answers

As described in the following links you can't use .svg files directly in your project. They first need to be converted into corresponding xml file . To do that you can use Vector Asset Studio. Here are those links

Svg in Android Studio

and

Importing svg file in Android Studio

If you are missing jar files required for it you can get it from here alongwith the tutorial also

SVG Integration in Android

UPDATE

I now understood the real problem for this error. This error occurs when you directly copy the svg file into your project. To be able to use svg properly, you need to import it as a vector asset.

like image 102
Vivek Mishra Avatar answered Sep 22 '22 00:09

Vivek Mishra