Android Studio is a fickle beast. At times surprisingly clever and useful, and other times a flaky nightmare.
The most recent issue I came across was when a Google Glass project suddenly stopped building with unresolved symbol errors. This manifests itself as all your “com.google.android.glass.*” imports failing, and the resulting use of any object from those libs causing compilation errors.
How to fix it
Eventually I checked my project dependencies and explicitly added the GDK as a library. Bingo, that sorted it out.
- Copy the gdk.jar
This will be in your Android SDK directory, under /add-ons/addon-google_gdk-google-19/libs
- Paste it into the libs folder in your project directory
- Go to File > Project Structure
- Select your module (default name is app)
- Click the Dependencies tab
- Click the “+” sign
- Navigate to the libs folder and select the gdk.jar file
- OK through everything
I have zero idea why the issue suddenly arose. As with so many other issues I’ve come across in my short time developing for Android, I’ve learned to FDM: fix, document, and move on.