注册

在布局中直接使用环信提供的u组件i会有布局报错的问题(EaseTitleBar),相关日志如下

2022-05-11 15:21:00.755 1837-1837/com.example.jstxapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.jstxapp, PID: 1837
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.jstxapp/com.example.jstxapp.activity.CusMesActivity}: android.view.InflateException: Binary XML file line #6 in com.example.jstxapp:layout/activity_cus_mes: Binary XML file line #6 in com.example.jstxapp:layout/activity_cus_mes: Error inflating class com.hyphenate.easeui.widget.EaseTitleBar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4060)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4247)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2613)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8668)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
Caused by: android.view.InflateException: Binary XML file line #6 in com.example.jstxapp:layout/activity_cus_mes: Binary XML file line #6 in com.example.jstxapp:layout/activity_cus_mes: Error inflating class com.hyphenate.easeui.widget.EaseTitleBar
Caused by: android.view.InflateException: Binary XML file line #6 in com.example.jstxapp:layout/activity_cus_mes: Error inflating class com.hyphenate.easeui.widget.EaseTitleBar
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:864)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1016)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:971)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1133)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1094)
at android.view.LayoutInflater.inflate(LayoutInflater.java:692)
at android.view.LayoutInflater.inflate(LayoutInflater.java:536)
at com.android.internal.policy.HwPhoneLayoutInflater.inflate(HwPhoneLayoutInflater.java:138)
at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:696)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
at com.example.jstxapp.activity.CusMesActivity.onCreate(CusMesActivity.java:14)
at android.app.Activity.performCreate(Activity.java:8214)
at android.app.Activity.performCreate(Activity.java:8202)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4033)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4247)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2613)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8668)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
2022-05-11 15:21:00.755 1837-1837/com.example.jstxapp E/AndroidRuntime: Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
at androidx.appcompat.app.AppCompatDelegateImpl.setSupportActionBar(AppCompatDelegateImpl.java:572)
at androidx.appcompat.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:159)
at com.hyphenate.easeui.widget.EaseTitleBar.initToolbar(EaseTitleBar.java:180)
at com.hyphenate.easeui.widget.EaseTitleBar.init(EaseTitleBar.java:92)
at com.hyphenate.easeui.widget.EaseTitleBar.(EaseTitleBar.java:62)
at com.hyphenate.easeui.widget.EaseTitleBar.(EaseTitleBar.java:56)
... 29 more

已邀请:

使用的是哪个sdk版本 EaseTitlebar是怎么引用的

3.9.1,找到问题的关键了如果不在EaseTitlebar中设置titleBarLeftImage这个属性就会报错

您好,问题解决了吗,声明对象的时候随便给这个titlebar赋值就可以就解决这个问题

要回复问题请先登录注册