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
}
5
Answers
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.
Recently i had same issue,
I fixed with below steps.
Project Gradle
App gradle
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
Try this. It works.
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 ) ).
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:
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 alreadyavailable .
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 ).
In Gradle.Properties add
android.useDeprecatedNdk=true android.enableAapt2=true android.enableUnitTestBinaryResources=false org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
In build.gradle(project)-> allprojects->repositories
add
configurations.all { resolutionStrategy.force "com.android.support:support-v4:26.1.0" }
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)->dependenciesand
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
in build.gradle(app) ->dependencieswhere
ext.kotlin_version = ‘1.8.0’ in build.gradle(project)->buildscript