cannot find symbol BR in android data binding参考解决方法

编译环境:gradle:3.2.0 

按照源码要求使用notifyPropertyChanged方法,仍一直报cannot find symbol BR in android data binding,重构什么都没效果。

源码:

/**
     * Notifies listeners that a specific property has changed. The getter for the property
     * that changes should be marked with {@link Bindable} to generate a field in
     * <code>BR</code> to be used as <code>fieldId</code>.
     *
     * @param fieldId The generated BR id for the Bindable field.
     */
    public void notifyPropertyChanged(int fieldId) {
        synchronized (this) {
            if (mCallbacks == null) {
                return;
            }
        }
        mCallbacks.notifyCallbacks(this, fieldId, null);
    }

在Stack Overflow上看到解决方案:

 在build.gradle(project:XXXX)文件中加 classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7'

试了一把还是没效果。继续看评论,一个哥们说:In case someone still has this problem. I solved this by invalidating the cache in Android Studio. And I'm using Android Studio 2 with API 23。

在试一把

file——>invalidate caches/restart...——>just restart   问题解决

如图:

如图:

 Stack Overflow :https://stackoverflow.com/questions/30776466/cannot-find-symbol-br-in-android-data-binding/

猜你喜欢

转载自blog.csdn.net/lala_peng/article/details/85686235