skip to Main Content

I am starting a new project by using the architecture-templates by google (https://github.com/android/architecture-templates)

In this template, they use Gradle with Kotlin DSL. I am trying to add Crashlytics to this project but the structure of gradle is quite different from my old projects.

I am stuck on the step 2 of the base guide (Firebase Get Started Documentation)

Error resolving plugin [id: ‘com.android.application’, version:
‘7.3.1’]

The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so
compatibility cannot be checked.

Any suggestion?

2

Answers


  1. Chosen as BEST ANSWER

    After some research I found that the architecture template is based on gradle 7.6 which use the version catalog feature.

    So I based my Version Catalog file on this https://github.com/RedMadRobot/gradle-version-catalogs/blob/main/versions-stack/libs.versions.toml

    Now my build.gradle.kts file is

    plugins {
        alias(libs.plugins.android.application)
        alias(libs.plugins.kotlin.android)
        alias(libs.plugins.kotlin.kapt)
        alias(libs.plugins.hilt.gradle)
        alias(libs.plugins.firebase.crashlitycs)
        alias(libs.plugins.gms.googleServices)
    }
    
    ....
    
    dependencies {
    
    implementation(platform(libs.firebase.bom))
    implementation(libs.firebase.crashlytics)
    implementation(libs.firebase.analytics)
    }
    

  2. I used to be confused about this too, but after some tries, I found the correct answer.
    I think this is the first point of step 2 where you are confused. Just add the following code at the top of the project level build.gradle:

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

    Just follow the Google guide for the rest.

    Complete code:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        dependencies {
            classpath 'com.google.gms:google-services:4.3.14'
        }
    }
    
    plugins {
        id 'com.android.application' version '7.2.2' apply false
        id 'com.android.library' version '7.2.2' apply false
        id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    Edited:

    DSL version:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        dependencies {
            classpath("com.google.gms:google-services:4.3.14")
            classpath("com.google.firebase:firebase-crashlytics-gradle:2.9.2")
        }
    }
    
    plugins {
        id("com.android.application") version "7.2.2" apply false
        id("com.android.library") version "7.2.2" apply false
        id("org.jetbrains.kotlin.android") version "1.7.10" apply false
    }
    
    tasks.register("clean", Delete::class) {
        delete(rootProject.buildDir)
    }
    

    This website(Gradle Kotlinize – Groovy to Kotlin converter online) may be able to help you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search