Android Studio 3.0.1无法解析依赖性。 Gradle项目同步失败

时间:2018-03-06 23:39:29

标签: android gradle

问题:
Gradle项目同步失败。基本功能(例如,编辑,调试)将无法正常工作。

Error:Unable to resolve dependency for ...compileClasspath:Could not resolve com.android.support...

尝试: 编辑build.gradle文件 - 没有工作。
检查离线 - 已经禁用。
Unistall并重新安装 - 不工作。
无效并重新启动 - 不工作。
关闭防病毒软件 - 没有帮助 更新到最新的gradle版本 - 没有。
删除gradle文件夹并让它再次下载 - 没有。
下载NDK - 没有。

到目前为止,我已尝试过从谷歌获得的许多流行方式,但没有任何效果。

操作系统是Windows 7.我今天再次尝试下载gradle,SDK和NDK以及AS,但仍然没有任何工作。我很确定它们是最新版本。

正如许多其他网站所述,添加了google()。 这是我的build.gradle文件。

build.gradle(project)

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle(模块应用)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.nina.myapplication"
        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 {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

0 个答案:

没有答案
相关问题