简体   繁体   English

将Firebase添加到我的Android项目时出现错误

[英]Getting error when adding firebase to my Android project

I am adding Firebase to my app, to use Crashlytics. 我正在将Firebase添加到我的应用中,以使用Crashlytics。 That's nice, but when I followed official guide to install it, I got error from Gradle, that google play services not found. 很好,但是当我按照官方指南进行安装时,我收到了Gradle的错误消息,即未找到Google Play服务。 Why it's telling me not found? 为什么告诉我没有找到?

My app is running latest Gradle "v3.4.1", and I searched for this problem, and got this answer: 我的应用程序正在运行最新的Gradle“ v3.4.1”,我搜索了此问题,并得到了以下答案:

So as a quick fix I added another repository, that has it: 因此,作为快速解决方案,我添加了另一个存储库:

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

Link: Error: could not find com.google.gms:google-services:4.2.0 链接: 错误:找不到com.google.gms:google-services:4.2.0

But that didn't help me, still getting not found error. 但这对我没有帮助,但仍然找不到错误。

Here is my Gradle config files: 这是我的Gradle配置文件:

Project gradle: 项目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
}

App Gradle: 应用程式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

Error from Gradle: 来自Gradle的错误:

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

Because google-services:4.2.0 is not available at Central Repository, so it needs to be downloaded from Android Tools Repository. 由于google-services:4.2.0在中央存储库中不可用,因此需要从Android工具存储库下载。 To add this to your project add this to build-script repositories. 要将其添加到您的项目中,请将其添加到构建脚本存储库中。 For more refer to https://mvnrepository.com/artifact/com.google.gms/google-services/4.2.0 有关更多信息,请参阅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()
    }
}

And in your app level build file, the Google-service plugin moves to the bottom. 在您的应用程序级别构建文件中,Google服务插件移至底部。

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

move 移动

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

to the bottom of your build.gradle file. 到build.gradle文件的底部。

more info: https://firebase.google.com/docs/android/setup 更多信息: https : //firebase.google.com/docs/android/setup

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Android添加到Phonegap项目时出现错误 - Getting error when adding Android to Phonegap project Android:我抓取我的项目时出现清单合并错误 - Android : Getting manifest merge error when I gradle my project 将Firebase添加到我的Android应用程序时发生Gradle错误 - Gradle error on adding firebase to my Android App 使用 appcompat-v7:28.0.0 将 Firebase Analytics 添加到 Android 项目时出错 - Error when adding Firebase Analytics to Android project with appcompat-v7:28.0.0 将Firebase消息添加到扑扑的android项目时出现依赖项错误 - dependency error while adding firebase messaging to a flutter android project 我的Android项目中不断出现错误 - I keep getting an error in my android project 获取我的Android Studio项目的运行时错误 - Getting runtime error for my android studio project 在项目libs文件夹中添加quickblox-android-0.8.1.jar文件并在设备上安装时出现错误后 - After Adding quickblox-android-0.8.1.jar file in project libs folder and getting error when install on device 尝试将 Firebase 添加到我的 android 项目时出现 gradle 同步错误 JAVA_LETTER_OR_DIGIT - I have a gradle sync error JAVA_LETTER_OR_DIGIT when trying to add Firebase to my android project 添加Firebase后出现Multidex错误原生android - getting Multidex error native android after adding firebase
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM