运行时SVG错误,但在Android Studio中不存在

时间:2018-09-04 12:29:37

标签: android android-studio svg

我已成功使用New-> Vector Asset将SVG文件成功加载到Android Studio中,该SVG文件可以很好地导入。

我可以添加一个imageView并引用SVG,在Android Studio中它可以正常显示。

enter image description here

运行应用程序时,在运行时出现错误;

 PID: 7369
 android.view.InflateException: Binary XML file line #33: Binary XML file line #33: Error inflating class ImageView
 Caused by: android.view.InflateException: Binary XML file line #33: Error inflating class ImageView

我已经完成了其他svg所需的所有工作,以使其可用,我之前从未遇到过svg遇到此错误的情况。

片段/ ImageView代码在下面;

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_height="match_parent"
android:id="@+id/relativeLayout3">

<ImageView
    android:id="@+id/imageView11"
    android:layout_width="263dp"
    android:layout_height="74dp"
    app:srcCompat="@drawable/ic_arabicflag"
    tools:layout_editor_absoluteX="43dp"
    tools:layout_editor_absoluteY="397dp" />

</android.support.constraint.ConstraintLayout>

堆栈跟踪在下面;

 E/AndroidRuntime: FATAL EXCEPTION: main
              Process: uk.co.futsalselect.app.futsalselect, PID: 7369
              android.view.InflateException: Binary XML file line #33: Binary XML file line #33: Error inflating class ImageView
              Caused by: android.view.InflateException: Binary XML file line #33: Error inflating class ImageView
              Caused by: android.content.res.Resources$NotFoundException: Drawable uk.co.futsalselect.app.futsalselect:drawable/ic_arabicflag with resource ID #0x7f070088
              Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_arabicflag.xml from drawable resource ID #0x7f070088
                  at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:725)
                  at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:571)
                  at android.content.res.Resources.getDrawable(Resources.java:767)
                  at android.content.Context.getDrawable(Context.java:525)
                  at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:351)
                  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:200)
                  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188)
                  at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100)
                  at android.support.v7.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:58)
                  at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:78)
                  at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:68)
                  at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
                  at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1024)
                  at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1081)
                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
                  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
                  at uk.co.futsalselect.app.futsalselect.tournament_fragment.onCreateView(tournament_fragment.java:21)
                  at android.app.Fragment.performCreateView(Fragment.java:2353)
                  at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:995)
                  at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1171)
                  at android.app.BackStackRecord.run(BackStackRecord.java:815)
                  at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1578)
                  at android.app.FragmentManagerImpl$1.run(FragmentManager.java:483)
                  at android.os.Handler.handleCallback(Handler.java:751)
                  at android.os.Handler.dispatchMessage(Handler.java:95)
                  at android.os.Looper.loop(Looper.java:154)
                  at android.app.ActivityThread.main(ActivityThread.java:6077)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
               Caused by: java.lang.IllegalArgumentException: Path string cannot be empty.
                  at android.util.PathParser.nCreatePathDataFromString(Native Method)
                  at android.util.PathParser.-wrap1(PathParser.java)
                  at android.util.PathParser$PathData.<init>(PathParser.java:74)
                  at android.graphics.drawable.VectorDrawable$VFullPath.updateStateFromTypedArray(VectorDrawable.java:1556)
                  at android.graphics.drawable.VectorDrawable$VFullPath.inflate(VectorDrawable.java:1507)
                  at android.graphics.drawable.VectorDrawable.inflateChildElements(VectorDrawable.java:693)
                  at android.graphics.drawable.VectorDrawable.inflate(VectorDrawable.java:598)
                  at android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.java:130)
                  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1227)
                  at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1200)
                  at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:715)
                    ... 33 more

图片文件太大,无法粘贴到这里。

是否有人成功导入了svg并在运行时导致错误?您做了什么来解决此问题?

0 个答案:

没有答案