question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unresolved reference. Forced to clean build after code changes

See original GitHub issue

Hi, I am having some problems with Hilt dependency injection. If I clean the project and build, it builds just fine. But gives me ‘Unresolved reference’ on a bunch of my injected view models if I change anything in my activities/fragments and try and build again without cleaning. Some builds also trigger a circular dependency error, but I cannot figure out where the should be occuring.

I have tried all different kinds of configurations in my gradle files, to no avail, I have tried to paste my configuration with the parts concerning dagger and gradle below:

build.gradle file

buildscript {
    ext.kotlin_version = '1.5.10'
    ext.hilt_version = '2.37'

    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
    }
}

build.gradle app file

plugins {
    id("dagger.hilt.android.plugin")
}

dependencies {
    implementation "com.google.dagger:hilt-android:$hilt_version"
    kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
}

I get the following error messages on subsequent builds, either unresolved reference or dependency cycle

Screenshot 2021-07-07 at 11 31 59 Screenshot 2021-07-07 at 11 58 28

Any help would be appreciated. I have exhausted a lot of different options by now.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
jorgenfaunaappcommented, Aug 18, 2021

I finally solved it! I am also using apollo-android to generated my types, mutations and queries for usage within my android project. In the Apollo schema directory I had a subfolder called User, I also had a package in my android project called user. This leads to two separate generated folders upon compilation, which for some unbeknownst reason works in the initial builds (or if changes are applied to all files in the package with identical naming) but not in subsequent builds.

I have created a question on the apollo-android repo, trying to explain the error in more detail. I do not know where to go from here, but I just wanted to share the problem in case anyone else had this very undescriptive error message.

apollo-android question: https://github.com/apollographql/apollo-android/issues/3306

Best regards Jørgen.

1reaction
bcorsocommented, Aug 5, 2021

@jorgenfaunaapp just to confirm, after enabling correctErrorTypes are you still seeing the Dagger/DependencyCycle error? If so can you post the updated stacktrace without the NonExistentClass?

For the unresolved references, I don’t see anything relating it to Hilt. Do you have a reason to suspect that this is related to Hilt?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Studio 3.1: Erroneous unresolved references in editor
Set Settings -> Build -> Gradle settings back (last stable Gradle local distribution in my case). Clean&rebuild project. Helps me. Share.
Read more >
Build fails with Unresolved reference when enabling view ...
1. Build cache enabled in gradle. · 2. Rename a top level package. · 3. Clean and build, Viewbinding classes are still generated...
Read more >
Unresolved reference when I move file in library module
It is about moving/creating files inside a project that was previously built using the daemon. I can reproduce this just by doing a...
Read more >
R is unresolved - #25 by mitra.1 - Android - Kotlin Discussions
I create a new project in Android Studio and when I create a new activity for my project the IDE display me an...
Read more >
Upgrading your build from Gradle 6.x to the latest
This may cause errors when you try to delete the root project directory after running a build with TestKit. For example, tests that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found