不幸的是,我已经经常遇到这个问题了,在我的Android项目中,我使用的是 databinding
and click OK.
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable name="myClass" type="com.somepackagename.myClass" />
</data>
</layout>
Make sure that both the variable name
and
checkbox are checked. Also make sure to check the
e: error: Cannot resolve type 'myClass'
e: error: cannot generate view binders android.databinding.tool.util.LoggedErrorException: failure, see logs for details.
Cannot resolve type 'myClass'
at android.databinding.tool.util.L.printMessage(L.java:134)
at android.databinding.tool.util.L.e(L.java:107)
at android.databinding.tool.expr.Expr.getResolvedType(Expr.java:386)
at android.databinding.tool.expr.ExprModel.lambda$resolveTypes$1(ExprModel.java:618)
...
checkbox and enter the following expression:
At some point during your build, if you have a databinding
, a breakpoint should be reached. In the debugger you should now see the exact error message the logger printed:
Now scroll down the Stacktrace on the left pane of the debug window and click the entryThe final step is easy. Using Android Studio, simply search for this class, for instance using: Edit → Find → Find in Path → "com.somepackagename.myClass". On the right side of the window, select File mask:
You should now see all xml files that caused the issue.Hope this helps someone in the future. Still IMO this is way to complicated. If anyone knows a better way to debug such issues, please let me know :) 基本上,我是按以下方式进行的。
在我的整个项目(相当大)中,我经常使用相同的
DatabindingDebugging
在做了很多重构之后,我现在不能再构建我的项目了,因为出现了以下构建错误。./gradlew assembleDebug --no-daemon -Dorg.gradle.debug=true -Dkotlin.compiler.execution.strategy="in-process" -Dkotlin.daemon.jvm.options="-agentlib:jdwp=transport=dt_socket\,server=y\,suspend=n\,address=5005"
是哪个xml文件导致了这个问题> Starting Daemon
哪种类型会导致这个问题DatabindingDebugging
难道就没有更好的方法来调试这种错误吗?Debug DatabindingDebugging
Ctrl + D
Connected to the target VM...
不幸的是,我已经经常遇到这个问题了。在我的Android项目中,我使用databinding来绑定类到我的xml布局上,工作正常。基本上我是按以下方式做的: ...+
首先,我要感谢这篇优秀文章的作者,他给了我一个很好的想法,让我知道该从哪里开始。1. Java Method Breakpoints
Class pattern: android.databinding.tool.util.L
根据上面的文章,下面应该可以快速找到导致错误的方法。Method name: printMessage
在Android Studio中添加一个新的配置。编辑→运行配置。给它起一个任意的名字,比如 Enabled
在终端窗口中执行。Suspend
. 构建过程中应打印 Condition
. 即它会等到你调试。kind.name.equals("ERROR")
回到Android Studio,在顶部的部分,你的新配置 ERROR
调试窗口现在应该启动,并显示如下内容 Cannot resolve type 'someType'
getResolvedType:386, Expr
在Android Studio的调试窗口中,手动添加一个新的断点。点击ViewBreakpoints(红色图标,有两个点)。在Breakpoints窗口中,通过点击添加一个新的断点。this.mUserDefinedType = "com.somepackagename.myClass"
左上角的图标,然后选择 *.xml