错误:无法解决:com.google.firebase:firebase-appindexing

时间:2019-02-27 23:07:54

标签: android

我在Gradle项目Sync中遇到此错误。  我从字面上试着做我在这里找到的所有事情,但没有一个起作用。这一切都是在我尝试将Firebase链接到我的项目时发生的。

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.example.shrinkio"
    minSdkVersion 19
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
}
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:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'android.arch.lifecycle:extensions:1.1.1'
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'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-appindexing'
}

apply plugin: 'com.google.gms.google-services'

3 个答案:

答案 0 :(得分:1)

尝试使用以下最新的Android Gradle

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

dependencies {
    classpath 'com.android.tools.build:gradle:3.3.1'
 }
}

答案 1 :(得分:1)

将“ build.gradle”文件代码更新为以下代码:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.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://jitpack.io" }
        maven { url 'https://maven.google.com' }
        //   mavenCentral()
        mavenLocal()
        maven { url "https://dl.bintray.com/drummer-aidan/maven" }

        mavenCentral()
        maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }

    }
}

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

然后转到“ gradle-wrapper.properties”并将最后一句话更改为以下代码:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

我希望这个答案对您有用

答案 2 :(得分:1)

该依赖项缺少版本号,应该是:

implementation "com.google.firebase:firebase-appindexing:17.1.0"

存储库为google()