首页 > 解决方案 > 错误:在 android studio 上更改类路径后无法解决问题

问题描述

将 build.gradle 上的依赖项的类路径更改为 后3.3.2,我收到此错误:

ERROR: Failed to resolve: com.android.support:appcompat-v7:28.0.0
Show in Project Structure dialog
Affected Modules: app


ERROR: Failed to resolve: com.android.support.constraint:constraint- 
layout:1.1.3
Show in Project Structure dialog
Affected Modules: app


ERROR: Failed to resolve: com.android.support.test:runner:1.0.2
Show in Project Structure dialog
Affected Modules: app


ERROR: Failed to resolve: com.android.support.test.espresso:espresso- 
core:3.0.2
Show in Project Structure dialog
Affected Modules: app

这是我的 build.gradle(Project: MyApplication) 文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        //"/home/hb3hbahan1/Android-Studio/android-studio/gradle/gradle-3.3.2.pom"
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:3.3.2'


        // 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(Module: App) 文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

编辑:我刚刚注释掉了除了 build.gradle(Module: app) 上的第 3 行之外的所有依赖项,并且错误消失了。这会影响我未来的调试等吗?

标签: androidgradleandroid-gradle-plugin

解决方案


推荐阅读