"无法解决:com.android.support:support-v4:26.0.0"和Gradle同步上的其他类似错误

Geo*_*e B 43 java android compiler-errors gradle wear-os

我刚刚为Android Mobile Wear 创建了一个新的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
}
Run Code Online (Sandbox Code Playgroud)

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'
}
Run Code Online (Sandbox Code Playgroud)

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+"
}
Run Code Online (Sandbox Code Playgroud)

我确信我的Android Studio版本已更新,并且已安装所有支持存储库和API. 在此输入图像描述

Kev*_*vin 77

我没有安装Android项目,但是当我想将现有项目的支持库版本升级到26.0.0时,我遇到了同样的问题.自26.0.0起,支持库可通过Google的Maven存储库获得.所以我不得不将存储库添加到我的构建中.gradle文件.

allprojects {
  repositories {
      jcenter()
      maven {
          url "https://maven.google.com"
      }
  }
}
Run Code Online (Sandbox Code Playgroud)

有关详细信息,请查看https://developer.android.com/topic/libraries/support-library/setup.html.


Par*_*der 11

以下对我有用:

在应用程序build.gradle中考虑添加以下内容:

allprojects {
repositories {
    maven {
        url "https://maven.google.com"
    }
}
}
Run Code Online (Sandbox Code Playgroud)

在模块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'
}
Run Code Online (Sandbox Code Playgroud)


Arj*_*uri 6

要么将构建工具版本更改为26.0.1,26.0.0要么可以替换26.0.026.+如下所示.

compile 'com.android.support:support-v4:26.0.0'
Run Code Online (Sandbox Code Playgroud)

compile 'com.android.support:support-v4:26.+"
Run Code Online (Sandbox Code Playgroud)

与所有人一样......希望它有所帮助.快乐的编码!^ _ ^


Geo*_*e B 1

我的项目出现这些错误的原因是因为我为 Android Platform 26 创建了项目。但是,Wear 目前不支持 26,因此必须在 build.gradle 文件的 Wear 模块中将 SDK 版本更改为 25 targetcompile梯度。

Android 开发者文档链接 - https://developer.android.com/training/wearables/apps/creating.html#setting-up-a-phone

build.gradle(磨损)

apply plugin: 'com.android.application'


android {
compileSdkVersion 25
buildToolsVersion "26.0.1"

defaultConfig {
    applicationId "com.georgeberdovskiy.findmyphone"
    minSdkVersion 25
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),       'proguard-rules.pro'
    }
    }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:2.0.3'
provided 'com.google.android.wearable:wearable:2.0.3'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.android.gms:play-services-wearable:11.0.4'

}

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

我只需要将 Wear 模块中的编译和目标 SDK 版本更改为 25。我为移动模块保留了 26。


归档时间:

查看次数:

51677 次

最近记录:

7 年,10 月 前