【问题标题】:Could not find support-media-compat.aar找不到 support-media-compat.aar
【发布时间】:2019-04-07 18:48:39
【问题描述】:

尝试Firebase 到一个 android gradle 应用程序。一旦我添加了 firebase 依赖项,我就会收到以下构建错误。

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find support-media-compat.aar (com.android.support:support-media-compat:26.1.0).
  Searched in the following locations:
      https://jcenter.bintray.com/com/android/support/support-media-compat/26.1.0/support-media-compat-26.1.0.aar
> Could not find support-core-utils.aar (com.android.support:support-core-utils:26.1.0).
  Searched in the following locations:
      https://jcenter.bintray.com/com/android/support/support-core-utils/26.1.0/support-core-utils-26.1.0.aar
> Could not find support-compat.aar (com.android.support:support-compat:26.1.0).
  Searched in the following locations:
      https://jcenter.bintray.com/com/android/support/support-compat/26.1.0/support-compat-26.1.0.aar
> Could not find support-compat.aar (com.android.support:support-compat:26.1.0).
  Searched in the following locations:
      https://jcenter.bintray.com/com/android/support/support-compat/26.1.0/support-compat-26.1.0.aar

看起来它只是在搜索 jcenter。但是 jcenter 的每个引用都有其他的 repos 列出来搜索。

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:3.2.0"

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

        classpath 'com.google.gms:google-services:4.2.0' // google-services plugin
    }
}

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

app/build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    defaultConfig {
        applicationId "io.nme.samples.displayingabitmap"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 181
        versionName "1.0.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    api fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    api 'com.android.support:appcompat-v7:24.2.1'
    api 'com.android.support:support-v4:24.2.1'

    testImplementation 'junit:junit:4.12'

    dependencies {

        api project(':extension-api')
        api project(':haxe-firebase')
    }

    implementation 'com.google.firebase:firebase-core:16.0.4'
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

我在这里错过了什么?

【问题讨论】:

  • 也显示您的应用级 Gradle。
  • 好的,我编辑了主要问题。

标签: android firebase android-gradle-plugin jcenter


【解决方案1】:

我在查找图书馆时遇到了同样的问题。但是,通过调整存储库顺序,此问题已得到解决。

repositories {
    google()
    jcenter()
    // others
}

看来我们首先要寻找的是由 google 托管的 maven 站点。

顺便说一句,maven { url 'https://maven.google.com'} 用于低于 4.1 的 Gradle 版本,而 google() 是较新的形式。另见this doc。

【讨论】:

  • 非常感谢,花了 30 多分钟才尝试。
  • 我在黑暗中尝试了这个作为一个镜头并且它有效 - 然后看到你评论了这个。哇。哇。
  • 您能否指定路径并进行编辑?
【解决方案2】:
api 'com.android.support:appcompat-v7:24.2.1'
api 'com.android.support:support-v4:24.2.1'

那是你的问题。即使没有 Firebase,这也应该引起问题。您正在使用 API 28 进行定位和构建,但您的支持依赖项位于 API 24。将它们更改为使用 28.0.0。

同时检查您的 extension-api 和 haxe-firebase 项目,确保它们使用最新的编译和 SDK 版本,以及构建工具版本和支持库版本。

【讨论】:

  • 谢谢!做到了。不知道那些必须同步。
  • 您能否指定路径并进行编辑?
【解决方案3】:

您必须替换 26.1.0 并使用版本 28.0.0 的支持库

【讨论】:

  • 我的项目中没有提到 26.1.0。不知道我该怎么做。
【解决方案4】:

在下面使用

buildscript {
ext.kotlin_version = '1.2.20'

repositories {
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'2.3.3
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
}
}

allprojects {
repositories
        {
            maven { url "https://dl.google.com/dl/android/maven2/" }
            maven { url "http://jcenter.bintray.com/" }
            maven { url 'https://plugins.gradle.org/m2/'}
            maven { url "https://maven.google.com" }
            maven { url 'https://jitpack.io' }
            mavenCentral()
            flatDir {
                dirs 'libs'
            }
        }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-20
    • 2018-11-13
    • 1970-01-01
    • 2019-12-30
    • 2017-03-08
    • 2020-01-24
    相关资源
    最近更新 更多