【问题标题】:Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/support/support-fragment/28.0.0/support-fragment-28.0.0.aar'无法获取资源“https://dl.google.com/dl/android/maven2/com/android/support/support-fragment/28.0.0/support-fragment-28.0.0.aar”
【发布时间】:2019-06-12 11:47:49
【问题描述】:

我想构建一个简单的基于片段的应用程序,但我无法加载库。

无法获取资源“https://dl.google.com/dl/android/maven2/com/android/support/support-fragment/28.0.0/support-fragment-28.0.0.aar”

我尝试了什么:

  1. 更新代理设置
  2. 删除代理
  3. 设置检查
  4. 检查连接
  5. 添加:
   // 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.4.1'

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

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

    }
}

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

Gradle.Properties


apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    defaultConfig {
        applicationId "com.example.fragmentmanagementmainactivity"
        minSdkVersion 23
        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:2.0.0-beta1'
    testImplementation 'junit:junit:4.13-beta-3'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:support-v13:28.0.0'
    implementation 'com.android.support:support-fragment:28.0.0'
}

一切都从实施“com.android.support:support-v4:28.0.0”开始 这不起作用

【问题讨论】:

  • 您可能希望包含更多的 gradle 文件,而不仅仅是这个。
  • 另一个,你声明你的依赖关系:)(如果你添加你已经拥有的google(),那么你不应该需要maven一个来处理appcompat的东西

标签: android fragment aar


【解决方案1】:
  1. 您要么在(应用)build.gradle 中导入了错误的依赖项,要么
  2. 您的设备/网络存在一些 DNS 问题。
  3. 你也可以试试这个; 将此添加到应用 build.gradle
repositories {
        maven { url "https://maven.google.com" }
    }

我希望是其中任何一个,因为它们很容易解决。让我知道它是否得到解决。

编辑:添加 3

【讨论】:

  • 到 1。我通过 Project Strukture 搜索添加了它们,所以它们对 2 没有错误。我检查连接(见上文),我可以在点击链接到 3 时手动下载文件。我已经做了
  • 我读过好几个这样的案例,主要是因为你的本地系统阻塞了网络请求。当您使用不同的网络/打开防火墙时它是否有效? stackoverflow.com/questions/45103230/…
  • 我尝试了另一个网络。这对我有用。请+1个问题
  • 您可以将其设置为接受的答案。 @Alpha-Centauri
猜你喜欢
  • 1970-01-01
  • 2021-05-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-11
  • 1970-01-01
  • 2021-12-08
  • 2019-03-07
相关资源
最近更新 更多