Unable to resolve imports from external dependencies in Android Studio 2.0 Preview 5 + Preview 6

After upgrading from the last Android Studio 2.0 preview to Preview 5 I’m having trouble with the imports from the android.support.wearable package.

Both the main app and Wear app builds and run just fine, but the editor in Android Studio complains that it can’t resolve the these imports

  • Does EditText.getText() ever returns null?
  • error: <identifier> expected using and
  • Tracking Android in-app subscription events with Firebase Analytics
  • ADT 22 - missing aapt.exe after upgrading
  • Android - Apache Mime & httpClient
  • Android Marshmallow Permissions Tests
  • import android.support.wearable.activity.WearableActivity;
    import android.support.wearable.view.CircledImageView;
    import android.support.wearable.view.WearableListView;

    In the Wear module’s build.gradle I have the following dependencies:

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile project(':common')
        compile 'com.android.support:appcompat-v7:23.1.1'
        compile 'com.android.support:support-v13:23.1.1'
        compile 'com.google.android.support:wearable:1.3.0'
        provided 'com.google.android.wearable:wearable:1.0.0'
        compile 'com.google.android.gms:play-services-wearable:8.4.0'

    As I understand from http://developer.android.com/training/wearables/apps/always-on.html#EnableAmbient this should work when using the provided statement. And it has worked well until the Android Studio upgrade. Am I missing something?


    This isn’t just a problem with the Wear library, it’s general for what seems to be any external dependency. (Topic originally was Unable to resolve package android.support.wearable in Android Studio 2.0 Preview 5.)

    It seems like the problem can occur at any time, but in practice it happens mostly whenever I do lotsa changes in a class (maybe changes to the imports?). Just now it suddenly was unable to resolve the imports of Play Services and Facebook ads (while still working for other dependencies).

    I accidentally found a workaround of the problem: If I open and build the project in Android Studio 1.5 which I also have installed, all the imports are fixed. Going back to Android Studio 2.0 I can continue programming without the imports becoming unresolvable for a long while.

    For anyone googling the problem, the error message in Android Studio is the usual Cannot resolve symbol ‘[package]’.

    Related posts:

    App Crashes On Startup Due To java.lang.IllegalArgumentException: column &#039;_id&#039; doe...
    List activity with header, footer and empty all visible
    How to limit ViewPager page changes to one per gesture
    Android radiogroup, divider between radiobuttons
    Reconnecting Emulator to Eclipse
    greendao delete from db and session
  • Why ImageView's getX, getY, setX and setY do not represent the actual value in the Relative Layout?
  • What happens when I unpublish an app from the Google Play market?
  • Android SeekBar setOnSeekBarChangeListener
  • Recyclerview not call any Adapter method :onCreateViewHolder,onBindViewHolder,
  • Integrate Google Voice Recognition in Android app
  • Android ArrayList of custom objects - Save to SharedPreferences - Serializable?
  • One Solution collect form web for “Unable to resolve imports from external dependencies in Android Studio 2.0 Preview 5 + Preview 6”

    I had this problem even before with AS 1.5, the easiest way for me to fix it was to use the Terminal inside Android Studio and execute:

    ./gradlew assembleDebug

    This will work if you’re not using flavors if not just use the name of the flavor, for e.g:

    ./gradlew assembleFlavorNameDebug

    that should work too as a workaround without leaving your current instance of AS, and then the compiler recognizes your imports if everything is setup properly.

    For more references please look: http://tools.android.com/build/gradleplugin

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.