Altaf
Altaf

Reputation: 5170

import android.support.wearable cannot be resolved

I am trying to develop a simple Android Wear app but I am facing problem:

import android.support.wearable cannot be resolved

enter image description here

Upvotes: 12

Views: 17123

Answers (7)

3c71
3c71

Reputation: 4541

Create a wearable module with Android Studio 4.0 and ended-up with the exact same issue! And it's 2020, 6 years later LOL.

Followed this guide to add the missing bits and pieces: https://developer.android.com/training/wearables/apps/creating

Basically my project builde.gradle didn't have those:

maven { url "https://maven.google.com" }

And this is module's gradle:

implementation 'com.google.android.support:wearable:2.8.0'

Once added, every checked properly.

PS: the maven is not even needed. Only missing implementation which clearly shows the wizard fails to create a valid module.

Upvotes: 1

Grim
Grim

Reputation: 2030

Maven?

AndroidSDK uses their very own repository. After download copy all from

C:\Program Files (x86)\Android\android-sdk\extras\google\m2repository\

To your repository. So this can be resolved:

<dependencies>
    <dependency>
        <groupId>com.google.android.wearable</groupId>
        <artifactId>wearable</artifactId>
        <version>1.0.0</version> <!-- or whatever -->
    </dependency>
</dependencies>

And you will get your

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.148 s
[INFO] Finished at: 2016-10-23T09:10:12+02:00
[INFO] Final Memory: 16M/15381M
[INFO] ------------------------------------------------------------------------

Upvotes: 0

Vikram
Vikram

Reputation: 1092

For gradle try

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:+'
compile 'com.google.android.gms:play-services-wearable:+'

}

Upvotes: 0

TacB0sS
TacB0sS

Reputation: 10266

in the spirit of @Wayne Piekarski answer, I've created a repository that stores the project as you will need it for developing in Eclipse, clone it -> add it as an Android Library -> DONE!

Lets keep it simple :)

==== UPDATE ====

And if you still encounter the WearableActivity... simply replace it with another Activity of you choice.

Upvotes: 3

JimsJump
JimsJump

Reputation: 31

The instructions detailed at the link below were very helpful for my Eclipse setup.

https://medium.com/@tangtungai/how-to-develop-and-package-android-wear-app-using-eclipse-ef1b34126a5d

Upvotes: 0

Wayne Piekarski
Wayne Piekarski

Reputation: 3232

The best way to get started with Android Wear is to use the latest Android Studio 0.8.1 or later, and it makes adding the support libraries to your code a lot easier. But it is possible to still use Eclipse, and I'll explain how to do it ...

Since the SDK was just released for Android Wear, you need to firstly make sure you follow these instructions to get everything up to date: http://developer.android.com/preview/google-play-services-wear.html

Here are the steps you need to do to fix your problem:

  1. Start SDK Manager.
  2. Update the Android SDK Tools and Platform-tools to versions 23 and 20 respectively.
  3. Click Tools > Manage Add-on Sites > User Defined Sites.
  4. Click New, enter https://dl-ssl.google.com/android/repository/addon-play-services-5.xml into the text field, and click OK.
  5. Click Close. You should now see lots of packages that need to be downloaded. You need to download "SDK Platform" under "Android 4.4W (API 20)
  6. The most important part is to download the "Google Repository" package under "Extras".
  7. Step 6 will produce a directory called $SDK/extras/google/m2repository/com/google/android/support/wearable/1.0.0 and in there will be a wearable-1.0.0.aar file
  8. Unzip the wearable-1.0.0.aar file, and it will produce a classes.jar file
  9. If you unzip -v classes.jar you will see that it contains android/support/wearable/view/WatchViewStuff.class, which is what you were looking for!
  10. Copy this classes.jar file to your project's libs directory, rename it to something like wearable-classes.jar
  11. Right click on the libs directory in Eclipse, which will refresh your project and you should see wearable-classes.jar
  12. Clean and rebuild your project.

These steps might seem complicated in having to deal with the .aar file ... It is a lot easier when working with Android Studio, since you can just add a gradle rule that does all these steps for you automatically:

dependencies {
    compile "com.google.android.support:wearable:1.0.+"
}

Upvotes: 11

nickjm
nickjm

Reputation: 422

In your Android SDK Manager, go to tools > manage add-on sites > user defined sites > new: https://dl-ssl.google.com/android/repository/addon-play-services-5.xml

Make sure you have the following (this is what I have)

1) Android SDK Tools v 23 (23.0.1 just came out)

2) Android SDK Platform-tools v 20

3) Android SDK Build-tools v 20

4) Android 4.4W (API 20)

5) Android Support Repository

6) Android Support Library

7) Everything else up to date

Resources: http://developer.android.com/preview/google-play-services-wear.html http://developer.android.com/training/wearables/apps/creating.html

Upvotes: 0

Related Questions