Получение ошибки при добавлении firebase в мой проект Android

Я добавляю Firebase в свое приложение, чтобы использовать Crashlytics. Это хорошо, но когда я следовал официальному руководству по его установке, я получил сообщение об ошибке от Gradle, что сервисы Google Play не найдены. Почему он говорит мне, что не найден?

В моем приложении работает последняя версия Gradle "v3.4.1", и я искал эту проблему и получил такой ответ:

Поэтому в качестве быстрого исправления я добавил еще один репозиторий, в котором он есть:

repositories {
    maven { url 'https://dl.bintray.com/android/android-tools' }
}

Ссылка: Ошибка: не удалось найти com.google.gms:google-services:4.2.0

Но это мне не помогло, ошибка все еще не найдена.

Вот мои файлы конфигурации Gradle:

Оценка проекта:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        // Check for v3.1.2 or higher
        classpath 'com.google.gms.google-services:4.2.0'

        // Add dependency
        classpath 'io.fabric.tools:gradle:1.29.0'


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

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

Приложение Gradle:

apply plugin: 'com.android.application'


android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.developerfromjokela.edison"
        vectorDrawables.useSupportLibrary = true
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 42
        versionName "3.4-BETA12"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {

            minifyEnabled false


            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }


}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-vector-drawable:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    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.android.support:recyclerview-v7:28.0.0'
    // Older okhttp because not working on android 4.0 for new versions
    //noinspection GradleDependency
    implementation 'com.squareup.okhttp3:okhttp:3.12.1'
    implementation "com.squareup.okhttp3:okhttp-urlconnection:3.0.0-RC1"
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.github.delight-im:Android-AdvancedWebView:v3.0.0'
    implementation 'de.hdodenhof:circleimageview:3.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.thoughtbot:expandablerecyclerview:1.4'
    implementation 'org.jsoup:jsoup:1.11.3'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation "com.android.support:support-emoji:28.0.0"
    implementation 'io.github.lizhangqu:coreprogress:1.0.2'
    implementation 'com.google.firebase:firebase-core:16.0.9'
}

apply plugin: 'com.google.gms.google-services'  // Google Play services Gradle plugin

Ошибка от Gradle:

ERROR: Could not find com.google.gms.google-services:4.2.0:.
Required by:
    project :
Search in build.gradle files

Попробуйте добавить apply plugin: 'com.google.gms.google-services' последним из dependencies{}

Dinesh Shingadiya 27.05.2019 15:25

Все еще не решаю мою проблему @DineshShingadiya

Developer From Jokela 27.05.2019 15:26

Добавьте maven { url 'https://maven.google.com/' } к своему allprojects { repositories { } }

Dinesh Shingadiya 27.05.2019 15:29

@DineshShingadiya Нет, это не помогло.

Developer From Jokela 27.05.2019 15:31
1
4
566
2
Перейти к ответу Данный вопрос помечен как решенный

Ответы 2

переехать

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

в конец вашего файла build.gradle.

подробнее: https://firebase.google.com/docs/android/setup

Все равно без разницы, моя первая проблема не исчезает, но я ее перенесу @Janekxyz

Developer From Jokela 27.05.2019 15:27

@DineshShingadiya этого не видел ;)

Janekxyz 27.05.2019 15:29

Моя проблема в градации на уровне проекта, поэтому давайте сначала решим ее, потому что мы здесь

Developer From Jokela 27.05.2019 15:30
Ответ принят как подходящий

Поскольку google-services:4.2.0 недоступен в центральном репозитории, его необходимо загрузить из репозитория инструментов Android. Чтобы добавить это в свой проект, добавьте это для создания репозиториев скриптов. Подробнее см. https://mvnrepository.com/artifact/com.google.gms/google-services/4.2.0

buildscript {
    repositories {
        jcenter()
        google()
        maven {
            url 'https://maven.fabric.io/public'
        }
        //  Add this to your project 
        maven { url 'https://dl.bintray.com/android/android-tools' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'

        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
        // These docs use an open ended version so that our plugin
        // can be updated quickly in response to Android tooling updates

        // We recommend changing it to the latest version from our changelog:
        // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
        classpath 'io.fabric.tools:gradle:1.27.0'
    }
}

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

И в вашем файле сборки на уровне приложения плагин службы Google перемещается в конец.

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

Другие вопросы по теме