【问题标题】:Why I can not add my project dependencies?为什么我不能添加我的项目依赖项?
【发布时间】:2019-03-25 01:20:53
【问题描述】:

当我开始一个新项目时,我看到以下关于我的依赖项的错误。 实际上,我正在使用VPN,但我不知道有什么问题?! 而且我之前没有这个问题,但是现在看到自从更新我的Android Studio后,我应该说我搜索了很多关于这个问题但没有找到任何解决方案

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-maps:16.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test:runner:1.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test.espresso:espresso-core:3.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-maps:16.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-maps:16.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-maps:16.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-maps:16.0.0.
Open File
Show Details

build.gradle(模块:app):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.pasargad.test_map"
        minSdkVersion 19
        targetSdkVersion 28
        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:28.0.0'
    implementation 'com.google.android.gms:play-services-maps:16.0.0'
    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(项目:...):

// 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.4'


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

【问题讨论】:

  • 你连接到互联网了吗?

标签: android android-studio gradle dependencies


【解决方案1】:

我找到了答案。问题是因为“gradle.properties”文件中的代理信息,我删除了所有关于代理的行(主机、密码等)并再次同步项目

【讨论】:

    【解决方案2】:

    确保 android studio 未处于离线模式并与互联网连接重新同步,如果所有这些都不起作用,那么


    1)转到文件资源管理器或其他东西上的android studio文件夹并转到gradle然后查看你的gradle文件(例如我的版本是gradle-4.6-all然后删除它)
    2)去 gradler office 网站并下载相同的 gradle 版本 gradle official site(例如 gradle v4.6)
    3)解压并粘贴到你被删除的地方
    4)重新与互联网连接同步

    【讨论】:

      【解决方案3】:

      首先请确保您已禁用 gradle 离线工作,如下图所示。

      现在将电脑连接到互联网。然后再次同步您的项目。它应该可以解决您的问题。

      【讨论】:

        猜你喜欢
        • 2016-05-17
        • 2015-05-07
        • 2015-11-06
        • 2015-09-12
        • 1970-01-01
        • 1970-01-01
        • 2014-09-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多