Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android wear - eclipse : not recognizing support library

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.

like image 937
Yakir Yehuda Avatar asked Jun 27 '14 22:06

Yakir Yehuda


People also ask

How do I get Android support library?

Downloading the Support LibrariesStart the android SDK Manager. In the SDK Manager window, scroll to the end of the Packages list, find the Extras folder. Select the Android Support Library item. Click the Install packages button.

What is an android support library?

In addition, the Support Libraries provide additional convenience classes and features not available in the standard Framework API for easier development and support across more devices. Originally a single binary library for apps, the Android Support Library has evolved into a suite of libraries for app development.


1 Answers

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.

like image 77
Maciej Ciemięga Avatar answered Oct 06 '22 16:10

Maciej Ciemięga