找不到support-media-compat.aar

时间:2018-11-04 01:18:58

标签: android firebase android-gradle jcenter

尝试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的每个引用都列出了要搜索的其他存储库。

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'

我在这里想念什么?

4 个答案:

答案 0 :(得分:8)

我遇到了有关查找库的相同问题。但是,通过调整存储库顺序,此问题已解决。

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

看来,由Google托管的Maven网站首先是我们要寻找的。

BTW, maven {url'https://maven.google.com'} 用于Gradle版本低于4.1的版本,而 google()是该版本的较新形式。另请参见this doc

答案 1 :(得分:4)

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-apihaxe-firebase项目,并确保它们使用的是最新的编译和SDK版本,以及构建工具版本和支持库版本。

答案 2 :(得分:1)

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

答案 3 :(得分:0)

在下面使用

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