Home > Net >  Hello! I can`t connect to firebase
Hello! I can`t connect to firebase

Time:05-11

**Could not parse the android application modules gradle config firebase. I don't know what to do,this is the first project.And I really can't solve it.

I've seen quite a lot of people getting this error, but it seems that they could solve it by upgrading their build tool version, or by updating google-services. I've done all that and haven't been able to make it work so far.

Here are my Gradle scripts:**

build.gradle(project)

buildscript {
    ext.kotlin_version = '1.6.21'
    repositories {
        google()
        mavenCentral()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.3'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20'
        classpath 'com.google.gms:google-services:4.3.10'
    }
}

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

build.gradle(module)

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'com.google.gms.google-services'
}
apply plugin: 'kotlin-android'

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.example.simplechatkotlin"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures{
        viewBinding true
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.6.0'
    implementation platform('com.google.firebase:firebase-bom:30.0.0')
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'com.google.firebase:firebase-database:20.0.5'
    implementation 'com.google.firebase:firebase-common-ktx:20.1.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation "androidx.core:core-ktx"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
    mavenCentral()
}

CodePudding user response:

The Kotlin Gradle plugin version should match the Kotlin version you're using, so it should be 1.6.21. And the latest build tools version is 7.1.2.

buildscript {
    ext.kotlin_version = '1.6.21'
    repositories {
        google()
        mavenCentral()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21'
        classpath 'com.google.gms:google-services:4.3.10'
    }
}
  • Related