When using compile 'com.google.android.support:wearable:2.0.4' I get the error below, but I am not using 26.0.0

匿名 (未验证) 提交于 2019-12-03 02:29:01

问题:

When using compile 'com.google.android.support:wearable:2.0.4' (the latest version of com.google.android.support:wearable) in my Wear app's build.gradle file, I get the error below, but I am not using 26.0.0.

What should I do? Even if I add compile 'com.android.support:wear:26.0.0' it still fails.

Error in the project's gradle file:   Error:(22, 13) Failed to resolve: com.android.support:wear:26.0.0 <a href="install.m2.repo">Install Repository and sync project</a><br><a href="openFile:/.../wear/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a> 

回答1:

Many of the Wear elements (BoxInsetLayout, WearableRecyclerView, SwipeDismissFrameLayout, full list here) have been moved to the main android support library (details). You can continue to use the old classes, but you probably want to use the latest stuff.

The build.gradle for your wear app includes compile 'com.google.android.support:wearable:2.0.4' which uses some classes from com.android.support:wear:26.0.0. As called out in link above, they were moved from com.google.android.support:wearable to com.android.support:wear.

The support libraries (26) are now in Google's Maven repository (not downloaded via the support repository from the SDK Manager), so you need to add Google's Maven Repository your top level build.gradle file.

In allprojects, within repositories, add the code below. It goes under the jcenter() call.

For the Android Gradle plugin revision 2.3.3 with Gradle 3.3 (Android Studio 2.3.3), your code should look like this:

allprojects {     repositories {         jcenter()         maven {             url "https://maven.google.com"         }     } } 

For the Android Gradle plugin revision 3.0.0 (in alpha right now) with Gradle 4.1 (might be milestone version) in Android Studio 3.0.0, your code should look like this:

allprojects {     repositories {         jcenter()         google()     } } 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!