I'm building a simple application using LiveData and viewmodels but iam getting the following warning messages in my activity surrodning my activity some of the warning
Cannot access 'androidx.activity.contextaware.ContextAware' which is a supertype of 'com.example.movies.presentation.home.MoviesActivity'. Check your module classpath for missing or conflicting dependencies
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
// ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$life_cycle_version"
// LiveData
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$life_cycle_version"
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
kapt "androidx.lifecycle:lifecycle-compiler:$life_cycle_version"
// Hilt
implementation "com.google.dagger:hilt-android:$hilt_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$life_cycle_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
//moshi
implementation("com.squareup.moshi:moshi:$moshi_version")
kapt("com.squareup.moshi:moshi-kotlin-codegen:$moshi_version")
//retrofit
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-moshi:$retrofit_version"
implementation("com.squareup.okhttp3:logging-interceptor:$okhttp_version")
//espresso testing
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_core"
androidTestImplementation "androidx.test:runner:$test_runner"
androidTestImplementation "androidx.test:rules:$test_runner"
// Hilt For instrumentation tests
androidTestImplementation "com.google.dagger:hilt-android-testing:$hilt_testing"
androidTestAnnotationProcessor "com.google.dagger:hilt-compiler:$hilt_testing"
//Hilt For local unit tests
testImplementation "com.google.dagger:hilt-android-testing:$hilt_testing"
testAnnotationProcessor "com.google.dagger:hilt-compiler:$hilt_testing"
//mockk for testing
testImplementation "io.mockk:mockk:$mockk_version"
//coroutine testing
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutine_test_version"
testImplementation("org.junit.jupiter:junit-jupiter-api:$junit_5")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junit_5")
testImplementation "android.arch.core:core-testing:$arch_version"
my module build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.31"
ext.hilt_version = '2.31.2-alpha'
ext.junit = '1.7.1.1'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
classpath "de.mannodermaus.gradle.plugins:android-junit5:$junit"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
life_cycle_version = "2.2.0"
espresso_core = "3.3.0"
test_runner = "1.3.0"
hilt_testing = "2.33-beta"
moshi_version = "1.10.0"
mockk_version = "1.11.0"
retrofit_version = "2.9.0"
okhttp_version = "4.9.0"
coroutine_test_version = "1.4.3"
junit_5 = "5.7.1"
arch_version = "2.2.0"
}
The class representing a car app activity. Base class for activities that want to use the support-based Fragments. A ContextAware class is associated with a Context sometime after the class is instantiated. By adding a OnContextAvailableListener, you can receive a callback for that event.
By adding a OnContextAvailableListener, you can receive a callback for that event. Classes implementing ContextAware are strongly recommended to also implement androidx.lifecycle.LifecycleOwner for providing a more general purpose API for listening for creation and destruction events.
A ContextAware class is associated with a Context sometime after the class is instantiated. By adding a OnContextAvailableListener, you can receive a callback for that event.
Classes implementing ContextAware are strongly recommended to also implement androidx.lifecycle.LifecycleOwner for providing a more general purpose API for listening for creation and destruction events. Add a new OnContextAvailableListener for receiving a callback for when this class is associated with a android.content.Context.
It was resolved when I added the activity jetpack module to the gradle file
def activity_version = "1.2.2"
// Java language implementation
implementation "androidx.activity:activity:$activity_version"
// Kotlin
implementation "androidx.activity:activity-ktx:$activity_version"
I got rid of this error message by upgrading the appCompat
library to the latest version from 1.2.0
to 1.3.0-rc01
.
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