I am working on an Android project that hasn’t been touched in some time. The previous developer left a few years ago and did not leave any documentation. I am encountering the following error when attempting to run the application:
error: ComponentProcessingStep was unable to process 'com.mrpg.mobile.app.check.App_HiltComponents.SingletonC' because 'dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' could not be resolved.
Dependency trace:
=> element (CLASS): androidx.hilt.lifecycle.ViewModelFactoryModules.ActivityModule
=> element (METHOD): provideFactory(android.app.Activity,android.app.Application,java.util.Map<java.lang.String,javax.inject.Provider<androidx.hilt.lifecycle.ViewModelAssistedFactory<? extends androidx.lifecycle.ViewModel>>>)
=> annotation: @dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory
=> type (ERROR annotation type): dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory
Here are the relevant gradle files:
app/build.gradle:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-allopen'
id 'kotlin-kapt'
id 'androidx.navigation.safeargs.kotlin'
id 'dagger.hilt.android.plugin'
}
apply from: "versions.gradle"
apply from: "configurator.gradle"
android {
namespace 'com.example.mobile_app_check'
compileSdkVersion build_versions.compile_sdk // 34
buildToolsVersion build_versions.build_tools // 34.0.0
testBuildType "release"
defaultConfig {
applicationId "com.mrpg.mobile.app.check"
minSdkVersion build_versions.min_sdk // 25
targetSdkVersion build_versions.target_sdk // 34
multiDexEnabled true
versionCode configurator.code
versionName configurator.name
setProperty("archivesBaseName", "${configurator.prefix}")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resValue "string", "display_build", configurator.release_current.toString()
resValue "string", "display_name", configurator.name
resValue "string", "display_type", configurator.type
resValue "string", "display_version", "${configurator.major}.${configurator.minor}.${configurator.patch}"
resValue "string", "start_fragment", configurator.start
}
compileOptions {
sourceCompatibility build_versions.java // JavaVersion.VERSION_1_8
targetCompatibility build_versions.java // JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = build_versions.jvm // 1.8
}
splits {
abi {
enable true
reset()
universalApk true
}
}
dataBinding {
enable = true
}
viewBinding {
enable = true
}
composeOptions {
kotlinCompilerExtensionVersion '1.5.1'
}
lintOptions {
abortOnError true
baseline file("lint-baseline.xml")
lintConfig file("lint.xml")
textReport true
textOutput "stdout"
xmlReport false
htmlReport false
disable "EnsureInitializerMetadata"
disable "NullSafeMutableLiveData"
disable "ObsoleteLintCustomCheck"
}
packagingOptions {
exclude "META-INF/DEPENDENCIES"
exclude "META-INF/NOTICE"
exclude "META-INF/LICENSE"
exclude "META-INF/LICENSE.txt"
exclude "META-INF/NOTICE.txt"
}
kapt {
correctErrorTypes true
}
buildTypes {
debug {
minifyEnabled false
shrinkResources false
}
release {
signingConfig signingConfigs.release
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile(
"proguard-android-optimize.txt"),
"proguard-rules.pro"
}
}
dependenciesInfo {
includeInApk false
includeInBundle false
}
ndkVersion build_versions.ndk
}
dependencies {
implementation "com.google.dagger:hilt-android:$library_versions.dagger_hilt" // 2.44
kapt "com.google.dagger:hilt-compiler:$library_versions.dagger_hilt" // 2.44
implementation "com.mrpg.mobile:pos-shared-library:$library_versions.mrpg_pos_shared"
}
build.gradle:
buildscript {
apply from: "versions.gradle"
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath "com.android.tools.build:gradle:$plugin_versions.gradle" // 8.5.1
classpath "com.google.dagger:hilt-android-gradle-plugin:$plugin_versions.hilt" // 2.44
classpath "org.jetbrains.kotlin:kotlin-allopen:$plugin_versions.kotlin" // 2.0.10
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$plugin_versions.kotlin" // 2.0.10
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$plugin_versions.safe_args" // 2.7.7
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
settings.gradle:
pluginManagement {
repositories {
google {
content {
includeGroupByRegex("com\.android.*")
includeGroupByRegex("com\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
}
rootProject.name = "mobile-app-check"
include ":app"
project(":app").projectDir = file("app")
I’ve tried updating dependencies and cleaning the project, but the issue persists. Any help or guidance would be greatly appreciated!