Error while compiling the code.
Type com.example.myhouse.MainActivity is defined multiple times: C:\Users\HP\AndroidStudioProjects\myHouse\app\build\tmp\kotlin-classes\debug\com\example\myhouse\MainActivity.class, C:\Users\HP\AndroidStudioProjects\myHouse\app\build\intermediates\javac\debug\classes\com\example\myhouse\MainActivity.class
Gradle file
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
id 'org.jetbrains.kotlin.android'
}
apply plugin: 'kotlin-android'
android {
compileSdk 31
defaultConfig {
applicationId "com.example.myhouse"
minSdk 21
targetSdk 31
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
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation("com.google.code.gson:gson:2.3.1")
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'androidx.annotation:annotation:1.3.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.firebase:firebase-database:20.0.3'
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
def lifecycle_version = "2.2.0"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "com.google.android.material:material:$version"
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:29.0.3')
// Declare the dependency for the Firebase Authentication library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-auth'
// Also declare the dependency for the Google Play services library and specify its version
implementation 'com.google.android.gms:play-services-auth:19.2.0'
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:29.0.4')
// Declare the dependency for the Firebase Authentication library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-auth'
// Also declare the dependency for the Google Play services library and specify its version
implementation 'com.google.android.gms:play-services-auth:20.1.0'
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.5.10'
implementation 'com.google.android.material:material:1.2.1'
}
Just delete build folder of appmodule and Rebuild the project!
or
Try to invalidate cache and restart
This will fix the issue!.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With