What is the location of android.databinding.Observable?

196 views Asked by At

Android Studio 3.0.1 is complaining that it can't find this class. Even though it builds, it just shows an awful red underline. That's my first question, but also curious where IS this elusive class?

Looking in the expanded libraries it doesn't show it: /Library/Android/sdk/extras/android/m2repository/com/android/databinding/library/1.3.1/library-1.3.1-sources.jar

And looking online for the source I'm also coming up short: https://android.googlesource.com/platform/frameworks/data-binding/+/c9a5d6f140f732ca0ff279a4b1ee315072e1c422/library/src/main/java/android/databinding

2

There are 2 answers

1
CommonsWare On BEST ANSWER

Android Studio 3.0.1 is complaining that it can't find this class. Even though it builds, it just shows an awful red underline

That's odd. I just pulled up a project in AS 3.0.1 that uses the data binding framework, and I can import android.databinding.Observable just fine.

Then again, Android Studio is... quirky.

where IS this elusive class?

In my environment, it is in com.android.databinding:baseLibrary:3.0.1:

Android Studio 3.0.1, Showing Data Binding Dependency

That, and com.android.databinding:adapters:1.3.1 and com.android.databinding:library:1.3.1, are added to your dependencies by the Android Gradle Plugin if you enable data binding.

0
Travis On

The link you provided refers to commit SHA c9a5d6f which is from some time ago:

git clone https://android.googlesource.com/platform/frameworks/data-binding
cd data-binding
git show c9a5d6f

commit c9a5d6f140f732ca0ff279a4b1ee315072e1c422
Author: George Mount <[email protected]>
Date:   Fri Jul 10 15:43:11 2015 -0700

Looking at the "current" (as of Nov 27, 2017), it is present:

ls baseLibrary/src/main/java/android/databinding/Observable.java