cannot find symbol BR in android data binding參考解決方法
阿新 • • 發佈:2019-01-03
編譯環境: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/