Android Wear Project Gradle Sync Fails

2020-02-17 02:52发布

问题:

I created a new project in Android Studio 0.8 in order to start integrating Android Wear into one of my apps. I create a new project and include the Wear form factor, but when I try to sync I get:

Error:Could not find any version that matches com.google.android.support:wearable:+. Required by: win_control:wear:unspecified

EDIT: I played around with Gradle a bit, and now I get these errors:

Error:Failed to find: com.google.android.gms:play-services-wearable:+ Open in Project Structure dialog
Open File

Error:Failed to find: com.google.android.support:wearable:+ Open in Project Structure dialog
Open File

回答1:

Had the same problem. Open up your Android SDK manager, go to tools -> manage add on sites, and add your own repo:

https://dl-ssl.google.com/android/repository/addon-play-services-5.xml

I finally found these helpful guides. There are lots of broken links and bad info floating around, but these should work:

http://developer.android.com/preview/google-play-services-wear.html

then,

http://developer.android.com/training/wearables/apps/creating.html

Also, double check your android sdk manager to make sure you have all the latest updates, as well as the android support repository/libraries!



回答2:

All the suggestion here at SO are now outdated.

What you should do is make sure "Google Repository" is checked and installed in the SDK manager.



回答3:

If all of these didn't work for you, check out the instructions at https://code.google.com/p/android/issues/detail?id=72454 For me, I was simply missing Google Repository from the extras section in the sdk manager



回答4:

If the SDK manager doesn't find any updates for you, it helped for me to wipe the m2repository folder under ~/.android/extras/google/.

You can manually add the update site by using your favorite text editor on ~/.android/repositories.cfg, it should look like this:

### User Sources for Android SDK Manager
#Wed Jul 02 10:15:39 EDT 2014
count=1
src00=https\://dl-ssl.google.com/android/repository/addon-play-services-5.xml


回答5:

I found out that, as of Android Studio 0.8.1, the option "Manage Add-On Sites" is absent from the Tools menu. Just in case someone else can't find it either, here's how to get to it :

1/ Go to Tools > Android > SDK Manager.

2/ Then, once the SDK Manager is opened, in the top menu go to Tools > Manage Add-On Sites.

There you go, then you just apply what nickjm said (thanks for the tip btw, I was wondering what was going on with this error message !).



回答6:

Adding the add on site did not work for me. In the android SDK, I simply opened up: Tools->Options...->Enable Preview Tools (Check it) Then it had an update for the wear stuff ... which I, of course, updated.

This allowed the library to be referenced by the IDE.