简体   繁体   English

我们如何将 Admob 和 Firebase crashlytics 添加到 Android Studio Bumble Bee Build.Gradle 文件中

[英]How can we add Admob and Firebase crashlytics to Android studio bumble bee Build.Gradle file

How can we add Admob and Firebase crashlytics to Android studio bumble bee我们如何将 Admob 和 Firebase crashlytics 添加到 Android Studio Bumble Bee

earlier the build.gradle: was some thing like this之前的 build.gradle: 是这样的

buildscript {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.4"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
        // Add the following line:
        classpath 'com.google.gms:google-services:4.3.10'  // Google Services plugin
        // Add the Crashlytics Gradle plugin
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'

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

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

However now the changes look like these然而现在的变化看起来像这些

plugins {
    id 'com.android.application' version '7.1.0' apply false
    id 'com.android.library' version '7.1.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false

    

}

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

I tried adding these lines我尝试添加这些行

// Add the following line:
        id 'com.google.gms:google-services' version '4.3.10' apply false
        // Google Services plugin
        // Add the Crashlytics Gradle plugin
        id 'com.google.firebase:firebase-crashlytics-gradle' version '2.8.1' apply false

But it error is但它的错误是

Caused by: org.gradle.plugin.internal.InvalidPluginIdException: plugin id 'com.google.gms:google-services' is invalid: Plugin id contains invalid char ':' (only ASCII alphanumeric characters, '.', '_' and '-' characters are valid)
    at org.gradle.plugin.use.internal.DefaultPluginId.validate(DefaultPluginId.java:65)
    at org.gradle.plugin.use.internal.DefaultPluginId.of(DefaultPluginId.java:48)
    at org.gradle.plugin.use.internal.PluginRequestCollector$PluginDependencySpecImpl.<init>(PluginRequestCollector.java:139)
    at org.gradle.plugin.use.internal.PluginRequestCollector$PluginDependencySpecImpl.<init>(PluginRequestCollector.java:129)
    at org.gradle.plugin.use.internal.PluginRequestCollector$PluginDependenciesSpecImpl.id(PluginRequestCollector.java:116)

Add com.google.gms.google-services and com.google.firebase.crashlytics like this:像这样添加com.google.gms.google-servicescom.google.firebase.crashlytics

plugins {
    id 'com.android.application' version '7.1.0' apply false
    id 'com.android.library' version '7.1.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false

    
    id 'com.google.gms.google-services' version '4.3.10' apply false  // Google Services plugin
    // Crashlytics Gradle plugin
    id 'com.google.firebase.crashlytics' version '2.8.1' apply false
}

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

Add buildscript above pluginsplugins上方添加buildscript

buildscript {
  dependencies {
    // Add our classpath 
     classpath 'com.google.gms:google-services:4.3.10'
     classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1' 
 }
}
 plugins {
      id 'com.android.application' version '7.1.0' apply false
      id 'com.android.library' version '7.1.0' apply false
}

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

In <project>/build.gradle :<project>/build.gradle

buildscript {
    repositories {
        google()
    }

    dependencies {
        classpath 'com.google.gms:google-services:4.3.13'
    }
}

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

And in <project>/<app-module>/build.gradle :<project>/<app-module>/build.gradle

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'com.google.gms.google-services'//this one
}

And this in dependencies:这在依赖项中:

implementation platform('com.google.firebase:firebase-bom:30.2.0')
implementation 'com.google.firebase:firebase-analytics-ktx'

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM