简体   繁体   English

Build.gradle:无法解决:com.android.support

[英]Build.gradle: Failed to resolve: com.android.support

I'm trying to build my Android Studio project, but I keep getting this "Failed to resolve: com.android.support" error. 我正在尝试构建我的Android Studio项目,但始终收到此“无法解决:com.android.support”错误。

This is how the build.gradle looks like: 这是build.gradle的样子:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "app.training.linus.trainingapp"
        minSdkVersion 26
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.exercise_card.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:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.google.android.gms:play-services-plus:15.0.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.exercise_card:runner:1.0.2'
    androidTestImplementation 'com.android.support.exercise_card.espresso:espresso-core:3.0.2'
}

And the other gradle file: 还有另一个gradle文件:

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

buildscript {

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


        // 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
}

I can't figure out why I can't build properly, I have the correct SDK version downloaded and everything. 我不知道为什么无法正确构建,下载了正确的SDK版本以及所有内容。

Thanks in advance! 提前致谢!

Removing 拆下

androidTestImplementation 'com.android.support.exercise_card:runner:1.0.2'
androidTestImplementation 'com.android.support.exercise_card.espresso:espresso-core:3.0.2'

Seems to have solved it! 似乎已经解决了!

Will You show me the error to know problem decently? 您能告诉我错误以体面地了解问题吗? generally, the integration problem occur if you update your studio reinstall the studio and connect with SDK you should check dependency in android studio 通常,如果您更新Studio重新安装Studio并连接SDK,则会出现集成问题,您应该检查android Studio中的依赖关系

'dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.google.android.gms:play-services-plus:15.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.exercise_card:runner:1.0.2'
androidTestImplementation 'com.android.support.exercise_card.espresso:espresso-core:3.0.2'

}' }'

you need to add in the project level gradle in allprojects 您需要在所有项目中添加项目级别gradle

 maven {
        url "https://maven.google.com"
    }


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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Build.gradle无法解析com.android.support - Build.gradle Failed to resolve com.android.support Gradle构建失败并出现错误无法解决:com.android.support - Gradle build failed with error Failed to resolve: com.android.support gradle构建失败错误:无法解决:com.android.support:cardview-v7:24.0.1和)无法解决:com.android.support:appcompat-v7:24.0.1 - gradle build fail Error: Failed to resolve: com.android.support:cardview-v7:24.0.1 and ) Failed to resolve: com.android.support:appcompat-v7:24.0.1 Gradle项目同步失败(无法解决:com.android.support:appcompat-v7:26.1.1) - Gradle project sync failed ( Failed to resolve: com.android.support:appcompat-v7:26.1.1) Android:build.gradle错误(“无法解决”) - Android: build.gradle error (“Failed to resolve”) 无法解决:构建gradle后com.android.support,但仍可以安装我的应用 - Failed to resolve: com.android.support after building gradle but my app can still be installed Gradle和Android:无法解析依赖项com.android.support - Gradle and Android: Could not resolve dependencies com.android.support 无法解析com.android.support:support-v4:23.2.1 - failed to resolve com.android.support:support-v4:23.2.1 无法解析:com.android.support:support-v4:23.0.0 - Failed to resolve: com.android.support:support-v4:23.0.0 无法解决:com.android.support:support-compat:27.2.0 - Failed to resolve: com.android.support:support-compat:27.2.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM