【问题标题】:Android studio 3 cannot download repository (error: Failed to download SHA1 for resource)Android studio 3 无法下载存储库(错误:无法下载资源的 SHA1)
【发布时间】:2018-04-30 20:44:02
【问题描述】:

我使用 android studio 3.0.0 版。

在更新之前,我使用 SDK 管理器来更新支持库。但更新 android studio 3 后,我应该通过https://dl.google.com/dl/android/maven2/ 更新。所以我需要支持库 26.1.0。

在异步 gradle 上我有这个错误:

Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve junit:junit:4.12.

Could not resolve junit:junit:4.12.
Required by:
    project :app > com.android.support.test:runner:1.0.1
 > Could not resolve junit:junit:4.12.
    > Failed to download SHA1 for resource 'https://dl.google.com/dl/android/maven2/junit/junit/4.12/junit-4.12.pom'.
          > For input string: "<!"

为什么不能下载这个:https://dl.google.com/dl/android/maven2/junit/junit/4.12/junit-4.12.pom

我使用代理但无法下载。

所有依赖库(appcampatv7、设计、注释等)都会显示此错误

如何解决此问题无法为资源下载 SHA1

更新:

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


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

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.example.testtesttest"
        minSdkVersion 15
        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'
    implementation 'com.android.support:design:26.1.0'
    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'
}

【问题讨论】:

  • repositories { .... maven { url 'https://maven.google.com' } ..... }
  • repositories { maven { url 'http://repo1.maven.org/maven2' } jcenter { url "http://jcenter.bintray.com/" } }
  • @IntelliJAmiya 这个设置在:allprojects { repositories { google() jcenter() } }.
  • 发布您的build.gradle
  • @IntelliJAmiya 更新

标签: android android-studio android-gradle-plugin android-support-library


【解决方案1】:

经过大量搜索后修复了这个问题。在gradle.propertices 文件中设置代理httphttps 并再次同步。

systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyPort=12345
org.gradle.jvmargs=-Xmx1234m
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=12345

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-14
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 2018-08-27
    • 2018-04-29
    • 2020-06-26
    相关资源
    最近更新 更多