Open loubingzhuxue opened 3 years ago
View is not a binding layout
Error inflating class com.test.sticker.StickerView
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.rInflate(LayoutInflater.java:1136)
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.chad.library.adapter.base.util.AdapterUtilsKt.getItemView(AdapterUtils.kt:15)
at com.chad.library.adapter.base.BaseQuickAdapter.createBaseViewHolder(BaseQuickAdapter.kt:653)
at com.chad.library.adapter.base.BaseQuickAdapter.onCreateDefViewHolder(BaseQuickAdapter.kt:649)
at com.chad.library.adapter.base.BaseQuickAdapter.onCreateViewHolder(BaseQuickAdapter.kt:274)
at com.chad.library.adapter.base.BaseQuickAdapter.onCreateViewHolder(BaseQuickAdapter.kt:75)
at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:7078)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6235)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2303)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1627)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:665)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4134)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3851)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4404)
at android.view.View.layout(View.java:22243)
at android.view.ViewGroup.layout(ViewGroup.java:6494)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1857)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1701)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1610)
at android.view.View.layout(View.java:22243)
at android.view.ViewGroup.layout(ViewGroup.java:6494)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:334)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at android.view.View.layout(View.java:22243)
at android.view.ViewGroup.layout(ViewGroup.java:6494)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1857)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1701)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1610)
at android.view.View.layout(View.java:22243)
at android.view.ViewGroup.layout(ViewGroup.java:6494)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:334)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at android.view.View.layout(View.java:22243)
at android.view.ViewGroup.layout(ViewGroup.java:6494)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1857)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1701)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1610)
at android.view.View.layout(View.java:22243)
at android.view.ViewGroup.layout(ViewGroup.java:6494)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:334)
at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:1084)
at android.view.View.layout(View.java:22243)
at android.view.ViewGroup.layout(ViewGroup.java:6494)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3518)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2998)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1996)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8462)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1256)
at android.view.Choreographer.doCallbacks(Choreographer.java:995)
at android.view.Choreographer.doFrame(Choreographer.java:887)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1224)
at android.os.Handler.handleCallback(Handler.java:900)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8387)
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:1055)
Caused by: java.lang.RuntimeException: Using WebView from more than one process at once with the same data directory is not supported. https://crbug.com/558377 : Lock owner com.test.sticker(pid 29328)
at org.chromium.android_webview.AwDataDirLock.a(PG:26)
at v7.g(PG:46)
at v7.a(PG:38)
at v7.b(PG:8)
at com.android.webview.chromium.WebViewChromiumFactoryProvider.a(PG:17)
at com.android.webview.chromium.WebViewChromium.init(PG:14)
at android.webkit.WebView.
class BackWarehouseReceiptDetailAdapter(
layoutResId: Int = R.layout.item_back_warehouse_receipt_detail_item,
data: MutableList<Object> = mutableListOf())
: BaseQuickAdapter<Object, BaseViewHolder>(layoutResId, data) {
init {
addChildClickViewIds(R.id.btn_fix_count)
}
override fun convert(holder: BaseViewHolder, item: Object) {
val binding = DataBindingUtil.getBinding(holder.itemView)
?: ItemBackWarehouseReceiptDetailItemBinding.bind(holder.itemView)
// other logic
}
}
com.chad.library.adapter.base.BaseQuickAdapter.kt
......
/**
* try to create Generic VH instance
*
* @param z
* @param view
* @return
*/
@Suppress("UNCHECKED_CAST")
private fun createBaseGenericKInstance(z: Class<*>, view: View): VH? {
try {
val constructor: Constructor<*>
// inner and unstatic class
return if (z.isMemberClass && !Modifier.isStatic(z.modifiers)) {
constructor = z.getDeclaredConstructor(javaClass, View::class.java)
constructor.isAccessible = true
constructor.newInstance(this, view) as VH
} else {
constructor = z.getDeclaredConstructor(View::class.java)
constructor.isAccessible = true
constructor.newInstance(view) as VH
}
} catch (e: NoSuchMethodException) {
// 抛出错误的地方是否能使用更"优雅"的方式记录
e.printStackTrace()
} catch (e: IllegalAccessException) {
e.printStackTrace()
} catch (e: InstantiationException) {
e.printStackTrace()
} catch (e: InvocationTargetException) {
e.printStackTrace()
}
return null
}
......
我也发现这个问题了 因为 empty header footer 不是binding 布局时候 会在控制台大量刷这个错误 并不影响使用 但是会干扰调试
我也遇到了这个问题。作者可以在 addHeaderView 或者 footerView 的时候提供一个传 R.layout 资源的接口,里面去用 databinding 拿,或者通过判断去绕过这个每次 try catch 打印日志
@Biswangluo 估计这个问题优先级太低排不上
BaseRecyclerViewAdapterHelper 实例 中也与这个日志>
DataBindingAdapter extends BaseQuickAdapter<Movie, BaseDataBindingHolder
W/System.err: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:343) at com.chad.library.adapter.base.BaseQuickAdapter.createBaseGenericKInstance(BaseQuickAdapter.kt:733) at com.chad.library.adapter.base.BaseQuickAdapter.createBaseViewHolder(BaseQuickAdapter.kt:675) at com.chad.library.adapter.base.BaseQuickAdapter.onCreateViewHolder(BaseQuickAdapter.kt:257) at com.chad.library.adapter.base.BaseQuickAdapter.onCreateViewHolder(BaseQuickAdapter.kt:75) at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:7078)