Android Studio 3.6
在我的xml中,我使用数据绑定:
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/path/to/picture.jpg"'
但是活动<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="testVariable"
type="java.lang.String" />
<variable
name="handler"
type="com.myproject.TestActivityJava" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/addTraderMainContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
在我的项目中不存在。因此,当我尝试运行(在Android Studio 3.6中)应用程序时,出现错误消息:
TestActivityJava
我去cannot find symbol
protected TestActivityJava mHandler;
^
symbol: class TestActivityJava
location: class TestActivityJavaBinding
e: myproject\app\build\generated\data_binding_base_class_source_out\debug\out\com\myproject\databinding\TestActivityJavaBinding.java:27: error: cannot find symbol
protected TestActivityJava mHandler;
^
symbol: class TestActivityJava
location: class TestActivityJavaBinding
error: cannot generate view binders android.databinding.tool.util.LoggedErrorException: failure, see logs for details.
Cannot resolve type 'handler'
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:370)
at android.databinding.tool.expr.ExprModel.lambda$resolveTypes$1(ExprModel.java:618)
at java.util.ArrayList.forEach(ArrayList.java:1257)
找到了:
TestActivityJavaBinding.java:27
此信息无济于事!!! 如您所见,Android Studio不能帮助我发现问题。 为什么Android Studio无法表明问题出在xml文件中?
P.S。删除xml后,问题消失了。我成功运行了我的应用程序。