我刚为Android Mobile 和佩戴创建了一个新的Android Studio项目。初始gradle构建失败,因为我收到了几个错误 -
Error: Failed to resolve: com.android.support:support-v4:26.0.0
Error: Failed to resolve: com.android.support:percent:26.0.0
Error: Failed to resolve: com.android.support:recyclerview-v7:26.0.0
Error: Failed to resolve: com.android.support:support-annotations:26.0.0
对于每个错误,我都可以选择Install repository and sync project
,但是当我点击它时没有任何反应。我花了几个小时试图找出我收到这些错误的原因,但我无法找到任何解决方案。有谁知道如何解决这些非常令人沮丧的错误?谢谢!
build.gradle(项目)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(移动)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.georgeberdovskiy.androidweartest"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso- core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
wearApp project(':wear')
compile 'com.google.android.gms:play-services-wearable:11.0.4'
compile 'com.android.support:appcompat-v7:26+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile "com.android.support:support-core-utils:26+"
testCompile 'junit:junit:4.12'
}
build.gradle(穿)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.georgeberdovskiy.androidweartest"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
provided 'com.google.android.wearable:wearable:2.0.4'
compile 'com.google.android.support:wearable:2.0.4'
compile 'com.google.android.gms:play-services-wearable:11.0.4'
compile "com.android.support:support-core-utils:26+"
}
答案 0 :(得分:76)
我没有Android佩戴项目,但是当我想将现有项目的支持库版本升级到26.0.0时,我遇到了同样的问题。自26.0.0起,支持库可通过Google的Maven存储库获得。所以我不得不将存储库添加到我的构建中。 gradle文件。
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
查看https://developer.android.com/topic/libraries/support-library/setup.html了解详情。
答案 1 :(得分:11)
以下对我有用:
在应用程序build.gradle中考虑添加以下内容:
allprojects {
repositories {
maven {
url "https://maven.google.com"
}
}
}
模块build.gradle中的:
compileSdkVersion 26
buildToolsVersion "26.0.1"
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services-wearable:11.0.4'
compile 'com.android.support:support-compat:26.0.1'
compile 'com.android.support:support-v4:26.0.1'
compile 'com.google.android.gms:play-services:11.0.4'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-annotations:26.0.1'
compile 'com.android.support:support-vector-drawable:26.0.1'
compile 'com.android.support:animated-vector-drawable:26.0.1'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:support-v13:26.0.1'
compile 'com.android.support:percent:26.0.1'
compile 'com.android.support:wear:26.0.1'
compile 'com.google.android.support:wearable:2.0.4'
provided 'com.google.android.wearable:wearable:2.0.4'
}
答案 2 :(得分:6)
将构建工具版本从26.0.1
更改为26.0.0
,或者您可以将26.0.0
替换为26.+
,如下所示。
compile 'com.android.support:support-v4:26.0.0'
到
compile 'com.android.support:support-v4:26.+"
对所有人都这样做...... 希望能帮助到你。 快乐的编码!的 ^ _ ^ 强>
答案 3 :(得分:3)
现在,我通过改变磨损build.gradle修复了这个问题:
gmsh-3.0.3-Windows
似乎问题是com.google.android.support:wearable:2.0.4。有了这个,使用26.0.1构建工具编译很好。我还没有进一步使用它,但它看起来像是与存储库相关的依赖性问题,尽管这只是从错误消息中猜测。
答案 4 :(得分:3)
在app/build.gradle
。
repositories {
maven { url 'https://maven.fabric.io/public' }
maven{url 'https://maven.google.com'}
}
答案 5 :(得分:2)
在您的gradle中添加以下依赖项
替换
compile 'com.android.support:support-v4:26.0.0'
与
compile 'com.android.support:support-v4:25.0.0'
并替换
compile 'com.android.support:appcompat-v7:26+'
与
compile 'com.android.support:appcompat-v7:25.0.0'
答案 6 :(得分:2)
替换它:
MobDetailsID
有了这个
Identity
对所有
执行相同操作更新 - 发布新版本
Save
答案 7 :(得分:1)
我的项目给我这些错误的原因是因为我为Android平台26创建了项目。但是,Wear目前不支持26,并且必须更改target
和{{1在build.gradle的wear模块中,SDK版本为25。
指向Android开发者文档的链接 - https://developer.android.com/training/wearables/apps/creating.html#setting-up-a-phone
build.gradle(穿)
compile
我只需要在wear模块中将编译和目标SDK版本更改为25。我把它们留给26作为移动模块。
答案 8 :(得分:1)
这个对我有用
allprojects {
repositories {
jcenter()
google()
}
}
google()通过以下配置实现了魔力
Studio版本: 3.0 beta 2
classpath 'com.android.tools.build:gradle:3.0.0-beta2'
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
答案 9 :(得分:0)
最后我只是改变了可穿戴版本,这个问题就消失了。
# name: 1.3.6.1.2.1.15.3.1.4.30.30.24.4
# pname: RFC1213-MIB::mib-2.15.3.1.4.30.30.24.4
到
provided 'com.google.android.wearable:wearable:2.0.4'
compile 'com.google.android.support:wearable:2.0.4'
顺便说一下,我现在使用离线构建,因为当我检查这个问题时,它真的很快。