6

Im trying to develop with the new Wear sdk.

I have downloaded everyting needed including support libraries and set up android wear to go. the problem I have is that the project cant find the wearable libararies.

code error lines example:

WatchActivity cannot be resolved to a type

and

The import android.support.wearable cannot be resolved

Thank you, Yakir.

Yakir Yehuda
  • 650
  • 7
  • 23

3 Answers3

12

I've gone through the same issues using Eclipse and the answer to my problem was following link that I've found:
http://blog.benjamin-cabe.com/2014/07/04/how-to-setup-eclipse-for-android-wear-development

WatchActivity:

just don't use WatchActivity - use standard Activity instead.

The import android.support.wearable cannot be resolved:

First step is to make sure that you have installed a Google Repository Extra in your SDK Manager. It should be located somewhere below the Android Support Repository
enter image description here

After downloading the Google Repository:
In Android Studio you just need to add a dependency for wearable-support lib like done here: https://developer.android.com/training/wearables/apps/layouts.html#UiLibrary.
But if you want to use any class from android.support.wearable package from Eclipse it is a little bit tricky.

Wearable package is not included in standard android-support library - you need to use wearable UI support lib located in google repository: com.google.android.support:wearable
Unlike the standard android-support libs, this one is not provided as a .jar file or project code that you can import right to your workspace, but it's in .aar format (like jar but also including res).

Please find this file here, relative to your sdk folder:
./extras/google/m2repository/com/google/android/support/wearable/1.0.0/wearable-1.0.0.aar

  1. Unzip wearable-1.0.0.aar file somwehere to your workspace (you can see it looks almost like a standard android project)
  2. Move classes.jar to /libs/classes.jar
  3. Now you have to create new project from these files, with package name defined as android.support.wearable
  4. Compile it with API 20 and select "Is Library" in project properties
  5. Add reference to this library project from your project

I recomment you to take a look at this blog post. There is everything explained well step-by-step. If you will have any project feel free to ask in comment here.

Maciej Ciemięga
  • 10,125
  • 1
  • 41
  • 48
  • My configurations - Eclipse Kepler - ADT Upto-date (checked by trying offline installation as well as online update service for eclipse) but still no luck in finding "wearable" folder/libs in the support folder (Also the path for the same you specified here, is different in windows). Any idea? – Vintesh Jul 17 '14 at 08:23
  • Im using windows and this path was from windows. What is your path to wearable-1.0.0.aar in google's m2repository? – Maciej Ciemięga Jul 17 '14 at 08:34
  • Path: .\sdk\extras\android\m2repository\com\android\support & in that i am not able to find "wearable" folder which is expected & there is no update available in my SDKManager as well as Eclipse. – Vintesh Jul 17 '14 at 08:47
  • The wearable support lib is not a part of Android Support Lib and it is not located in /extras/android but in /extras/google. Have you downloaded a "Google Repository" from SDK Manager? (It should be somewhere below the "Android Support Repository" in "Extras" section of your SDK Manager) – Maciej Ciemięga Jul 17 '14 at 08:49
  • Ahhaa... Installed "Google Repository" & It works. Thank You. – Vintesh Jul 17 '14 at 09:07
  • 1
    No problem. I will add it to my answer to highlight this step, because many people can be confused with the "Google repository" instead of "Android Support Repository". – Maciej Ciemięga Jul 17 '14 at 09:13
0

You can disregard the WatchActivity compile error, see my answer here: https://stackoverflow.com/a/24463815/592153.

If you can't find android.support.wearable, make sure you've followed step 4. in this guide: http://developer.android.com/preview/google-play-services-wear.html

Community
  • 1
  • 1
Sveinung Kval Bakken
  • 3,715
  • 1
  • 24
  • 30
  • Under `~/.android/extras`, do you see these file ./extras/google/google_play_services/docs/reference/com/google/android/gms/wearable ./extras/google/m2repository/com/google/android/gms/play-services-wearable ./extras/google/m2repository/com/google/android/gms/play-services-wearable/5.0.77 ./extras/google/m2repository/com/google/android/support/wearable ./extras/google/m2repository/com/google/android/support/wearable/1.0.0 If not, try deleting the `/extras/google` folder and downloading it again from the SDK Manager. – Sveinung Kval Bakken Jul 07 '14 at 15:50
0

You can find the wearable library inside Google Repository folder. On how to extract and use it, you can refer to https://medium.com/@tangtungai/how-to-develop-and-package-android-wear-app-using-eclipse-ef1b34126a5d

Hope this help

Tang Tung Ai
  • 151
  • 2