3

I connected firebase and I got this error, how can I fix it? (Class 'com.google.firebase.auth.ktx.AuthKt' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.)

build.gradle

buildscript {
    ext {
        compose_version = '1.1.0-beta01'
    }

    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.
plugins {
    id 'com.android.application' version '7.2.1' apply false
    id 'com.android.library' version '7.2.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Ryan M
  • 18,333
  • 31
  • 67
  • 74
TriangleN
  • 167
  • 1
  • 1
  • 7

5 Answers5

4

Recently i had same issue,

I fixed with below steps.

Project Gradle

 classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10' 
 or 
 id 'org.jetbrains.kotlin.android' version '1.7.10' apply false

App gradle

implementation "org.jetbrains.kotlin:kotlin-reflect:1.7.10" 

You can find more details on the below thread. Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15

Ashvin solanki
  • 4,802
  • 3
  • 25
  • 65
2

Try this. It works.

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

    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
Mayvas
  • 569
  • 4
  • 16
1

Because of the Kotlin version of your Gradle project. Gradle forces and old version of Kotlin. So the solution is:

Firstly, you need to update your Kotlin plugin in Android Studio to the latest version.

Second, go to /android/build.gradle and use this code below (note: if the latest kotlin version is greater than > 1.7.20, you need to change 1.7.20 to x.x.x ( x.x.x is the latest Kotlin version ) ).

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

    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
0

Hopefully this help you in some sort of way. I have encountered the same exact issue even the GPT failed to help me out, The accepted answer might work for you but it didn't for me what worked was a set of steps:

  1. Update the Android studio if not already and update suspected dependencies in build.gradle(app) after that add implementation 'com.android.support:appcompat-v7:26.1.0' if not already available .

  2. In project Structure make sure you have compatible (Gradle Plugin version, Gradle version and Gradle JDK mine were 7.0.2,7.2 and 11 ).

  3. In Gradle.Properties add android.useDeprecatedNdk=true android.enableAapt2=true android.enableUnitTestBinaryResources=false org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8

  4. In build.gradle(project)-> allprojects->repositories add configurations.all { resolutionStrategy.force "com.android.support:support-v4:26.1.0" }

  5. Make sure you have same version of kotlin in both build.gradles e.g: classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" in build.gradle(project)->dependencies and implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" in build.gradle(app) ->dependencies where ext.kotlin_version = '1.8.0' in build.gradle(project)->buildscript

TPX
  • 1
  • 4
-1

Try downgrading kotlin version from 1.7.1 to 1.5.1. Your current version is causing the issue as firebase auth dependency is not compatible with your current kotlin version.

Uzzam Altaf
  • 303
  • 4
  • 8