SVG Android异常

SVG Android异常,android,imageview,svg-android,Android,Imageview,Svg Android,我在处理SVG android库时遇到了一些问题。在我的主要活动中,我希望在imageview上显示SVG对象,但是,我遇到了这个错误 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidsvgdemo/com.example.androidsvgdemo.MainActivity}: com.larvalabs.svgandroid.SVGParseException: o

我在处理SVG android库时遇到了一些问题。在我的主要活动中,我希望在imageview上显示SVG对象,但是,我遇到了这个错误

java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.androidsvgdemo/com.example.androidsvgdemo.MainActivity}:
com.larvalabs.svgandroid.SVGParseException: 
org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 0: not well-formed (invalid token)
我的代码如下:

package com.example.androidsvgdemo;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

import com.larvalabs.svgandroid.SVG;
import com.larvalabs.svgandroid.SVGParser;

import android.os.Bundle;
import android.widget.ImageView;
import android.app.Activity;

public class MainActivity extends Activity {

    ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        imageView = (ImageView)findViewById(R.id.img1);
        //Parse the SVG file from the resource
        SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.imageandroid);
        //Get a drawable from the parsed SVG and apply to ImageView
        imageView.setImageDrawable(svg.createPictureDrawable());

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

请给我一些建议。谢谢。

错误表明SVG文件的XML格式不正确。。。您需要使用编辑并再次保存它。这应该重新编写您的SVG文件。

不幸的是,它似乎没有读取Inkscape SVG文件,请尝试以下方法:您的文件使用与SVG basic不兼容的内容,同时,尝试从SVG中删除组以及应用到的转换:translate和matrix…这不是我的文件,这是问题的根源。如果有命令行工具可以做到这一点,我可能会对它们进行预处理。你知道吗?这是另一个问题。。。Inkscape不提供将svg文件保存为svg Basic的方法(可以使用illustrator)。您尝试使用的文件包含矩阵变换,inkscape不知道如何删除它。您可以打开文件并使用1)选择所有CTRL+SHIFT+A 2)多次取消组合所有CTRL+SHIFT+G 3)简化路径CTRL+L 4)保存文件。这也将删除矩阵变换。。。但某些路径将被改变(贝塞尔曲线)。最好的解决方案是使用Illustrator。