android.view.InflateException错误输出类com.android.internal.widget.ActionBarContextView

时间:2016-02-15 05:04:40

标签: android compiler-errors android-actionbar

当我选择尝试加载活动时,我从logcat收到以下错误。 XML的第44行只是一个比例输入。我只在某些手机上收到此错误。

string1 = "abcdefga"
string2 = "acd"

for ch in string2:
    string1 = string1.replace(ch, '', 1)

print(string1)
'befga'

活动的XML

    02-14 23:50:46.555 9733-9733/com.example.jj.fragments E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.jj.fragments, PID: 9733
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.jj.fragments/com.example.jj.fragments.CurrentChat}: android.view.InflateException: Binary XML file line #44: Error inflating class com.android.internal.widget.ActionBarContextView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3149)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: android.view.InflateException: Binary XML file line #44: Error inflating class com.android.internal.widget.ActionBarContextView
at android.view.LayoutInflater.createView(LayoutInflater.java:640)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:4262)
at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:4334)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:440)
at android.app.Activity.setContentView(Activity.java:2358)
at com.example.jj.fragments.CurrentChat.onCreate(CurrentChat.java:96)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3102)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:614)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:4262)
at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:4334)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:440)
at android.app.Activity.setContentView(Activity.java:2358)
at com.example.jj.fragments.CurrentChat.onCreate(CurrentChat.java:96)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3102)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.RuntimeException: Failed to resolve attribute at index 13
at android.content.res.TypedArray.getDrawable(TypedArray.java:774)
at android.view.View.<init>(View.java:4009)
at android.view.ViewGroup.<init>(ViewGroup.java:513)
at com.android.internal.widget.AbsActionBarView.<init>(AbsActionBarView.java:74)
at com.android.internal.widget.ActionBarContextView.<init>(ActionBarContextView.java:103)
at com.android.internal.widget.ActionBarContextView.<init>(ActionBarContextView.java:98)
at com.android.internal.widget.ActionBarContextView.<init>(ActionBarContextView.java:94)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:614)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:4262)
at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:4334)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:440)
at android.app.Activity.setContentView(Activity.java:2358)
at com.example.jj.fragments.CurrentChat.onCreate(CurrentChat.java:96)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3102)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

1 个答案:

答案 0 :(得分:0)

您的问题不在于按比例输入。您正在使用

    com.android.internal.widget.ActionBarContextView

确保使用适当的操作栏为您的应用使用材质主题或appcompat主题。