尝试进行聊天活动时,我有此日志(当然是由于我的活动崩溃)。我正在跟踪smack xmpp聊天应用程序的教程,仅当我尝试打开聊天活动时才会发生:关于对第2行我可以做什么的任何建议?问候语:
Unable to start activity ComponentInfo{com.testproject.rooster/com.testproject.rooster.ChatActivity}: android.view.InflateException: Binary XML file line #13: Error inflating class co.devcenter.androiduilibrary.ChatView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2411)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2474)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5696)
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:1028)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class co.devcenter.androiduilibrary.ChatView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.testproject.rooster.ChatActivity.onCreate(ChatActivity.java:16)
at android.app.Activity.performCreate(Activity.java:5958)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2474)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5696)
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:1028)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: java.lang.ClassNotFoundException: Didn't find class "co.devcenter.androiduilibrary.ChatView" on path: DexPathList[[zip file "/data/app/com.testproject.rooster-1/base.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/system/lib, /vendor/lib, system/vendor/lib, system/vendor/lib/egl, system/lib/hw]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.view.LayoutInflater.createView(LayoutInflater.java:571)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.testproject.rooster.ChatActivity.onCreate(ChatActivity.java:16)
at android.app.Activity.performCreate(Activity.java:5958)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2474)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5696)
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:1028)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Suppressed: java.lang.ClassNotFoundException: co.devcenter.androiduilibrary.ChatView
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 23 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
我的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".ChatActivity">
<co.devcenter.androiduilibrary.ChatView
android:id="@+id/rooster_chat_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</co.devcenter.androiduilibrary.ChatView>
</RelativeLayout>
必须导入的gradle文件。 build.gradle
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation ('com.github.timigod:android-chat-ui:v0.1.3'){
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
exclude module: 'support-v4'
}
答案 0 :(得分:0)
好像没有正确包含库com.github.timigod:android-chat-ui
。
确保该行:
implementation 'com.github.timigod:android-chat-ui:v0.1.3'
位于dependencies {}
部分中。
喜欢这个档案
https://github.com/blikoon/Rooster/blob/master/Rooster/app/build.gradle
答案 1 :(得分:0)
找不到类
"co.devcenter.androiduilibrary.ChatView"
首先,请确保您已添加:
maven { url 'https://jitpack.io' }
在Build.gradle
文件的存储库中:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
第二,错误提示它找不到该类,而且在文档和库中找不到包名称looks different,而不是您在xml代码中添加的类。>
因此,将依赖项替换为:
implementation 'com.github.timigod:android-chat-ui:v0.1.4'
然后使用此标记:
<co.intentservice.chatui.ChatView
代替:
<co.devcenter.androiduilibrary.ChatView