我刚刚开始在Oreo上测试我的应用程序,而且我得到的是一个非常基本的致命异常,我没有在早期版本的Android上获得。
10-14 21:03:38.004 6833-6833/com.nooriginalthought.yabs E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.nooriginalthought.yabs, PID: 6833
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nooriginalthought.yabs/com.nooriginalthought.yabs.MainActivity}: android.view.InflateException: Binary XML file line #428: Binary XML file line #428: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: android.view.InflateException: Binary XML file line #428: Binary XML file line #428: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #428: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:418)
at android.app.Activity.setContentView(Activity.java:2654)
at com.nooriginalthought.yabs.MainActivity.onCreate(MainActivity.java:155)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
在此之后,我为矢量绘制资源收到了一堆android.content.res.Resources$NotFoundException
错误 - 尽管这些错误在早期版本的Android中完美运行。
这是在Android Studio模拟器中进行测试,因为我无法访问Oreo设备。
错误似乎都非常模糊 - 我的代码中唯一指向任何一行的错误指向调用正确布局setContentView(R.layout.main);
的行。
main.xml中的第428行(布局文件中正在膨胀并在错误中引用的行)如下:
<Button
android:id="@+id/email_button"
android:layout_width="50dp"
android:layout_height="32dp"
android:background="@drawable/ic_yabs_email_144x92"
android:backgroundTint="#ffff"
android:paddingRight="8dp"
android:paddingTop="8dp"
android:textColor="#ffff"
android:textSize="12dp" />
答案 0 :(得分:1)
感谢@David Medenjak指出错误中引用的行是我的布局文件中的实际行,我调查了该布局项中使用的向量drawable。
从drawable的XML中删除此行修复了错误。
<path android:fillColor="#000000" android:pathData="" android:strokeWidth="0.48000002"/>
我猜道没有pathData
的路径会以某种方式杀死事物。