简体   繁体   English

如何在Eclipse中为Android Wear导入“ android.support.wearable.watchface”?

[英]How to import “android.support.wearable.watchface” in Eclipse for Android Wear?

I'm doing my best to figure out how to develop apps in Eclipse for Android Wear (I really don't like Android Studio). 我正在尽力找出如何在Eclipse中为Android Wear开发应用程序(我真的不喜欢Android Studio)。 I have made a couple of apps so far for Android Wear in Eclipse that work perfectly fine, but I'm running into a big problem when trying to create a Watch Face. 到目前为止,我已经为Eclipse中的Android Wear开发了一些应用程序,它们运行正常,但是尝试创建表盘时遇到了一个大问题。

I can't import the following: 我无法导入以下内容:

import android.support.v7.graphics.Palette;
import android.support.wearable.watchface.CanvasWatchFaceService;
import android.support.wearable.watchface.WatchFaceService;
import android.support.wearable.watchface.WatchFaceStyle;

I have added the wearable-1.0.0.aar as a library as discussed here . 我已将可穿戴1.0.0.aar添加为此处讨论的库。 I have tried adding as an external jar the "android-support-v7-appcomapt.jar" file located at "...sdk\\extras\\android\\support\\v7\\appcompat\\libs", but still no luck. 我尝试将位于“ ... sdk \\ extras \\ android \\ support \\ v7 \\ appcompat \\ libs”中的“ android-support-v7-appcomapt.jar”文件作为外部jar添加,但是仍然没有运气。

I am using the "Watchface" example given by google. 我使用的是Google提供的“ Watchface”示例。 When using it in Android Studio it works perfectly fine. 在Android Studio中使用它时,效果很好。 The exact error I'm getting is: 我得到的确切错误是:

CanvasWatchFaceService cannot be resolved to a type

Also, in my project under Android Private Libraries I have "classes.jar" and "android-support-v4.jar". 另外,在我的Android私有库下的项目中,我有“ classes.jar”和“ android-support-v4.jar”。

Does anyone have a fix? 有人修复吗? I figure it has something to do with external libraries and/or a jar I've missed. 我认为这与外部库和/或我错过的jar有关。

Managed to figure it out. 设法弄清楚了。 For anyone else who comes across this thread, the answer lies in the wearable-1.0.0 library in that it does not contain CanvasWatchFaceService. 对于遇到此线程的其他任何人,答案就在可穿戴-1.0.0库中,因为它不包含CanvasWatchFaceService。 After looking through some of the other wearable projects, I found that the later versions have it. 在浏览了其他一些可穿戴项目之后,我发现更高版本的版本具有它。 Just go to ...sdk\\extras\\google\\m2repository\\com\\google\\android\\support\\wearable. 只需转到... sdk \\ extras \\ google \\ m2repository \\ com \\ google \\ android \\ support \\ wearable。 I chose the wearable-1.4.0 version. 我选择了可​​穿戴1.4.0版本。

Also, I added the external jar "android-support-v7-palette.jar" from the Android tools folder. 另外,我从Android tools文件夹中添加了外部jar“ android-support-v7-palette.jar”。

Now everything works perfectly for me. 现在,一切对我来说都很完美。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM