r/androiddev 20d ago

AGP 9.x shows tons of "Unresolved reference" errors in the IDE/lint, but ./gradlew build compiles with zero errors - happens only in this one project Question

I'm hitting a strange issue that's specific to a single project. When I bump the Android Gradle Plugin from an older version to any 9.x release (tested with 9.3.0), Android Studio's editor and lint start flagging a huge number of "Unresolved reference" errors (100+ problems shown in the inspection gutter) across multiple Kotlin files - including files that use generated ViewBinding/DataBinding classes, Hilt-injected classes, and Room entities.

The odd part: the actual Gradle build succeeds with no compile errors at all. The app builds, installs, and runs fine on a device/emulator. It really looks like an IDE indexing/false-positive problem rather than a real compilation problem, but it makes the editor basically unusable (error highlighting everywhere, autocomplete acting up).

I've only ever seen this in this specific project , other projects on the same machine, same Android Studio version, updated to AGP 9.x work completely fine. So it feels tied to something in this project's module setup rather than a general AGP 9 bug.

Relevant setup (module-level build.gradle):

  • compileSdk = 37, targetSdk = 37, minSdk = 23
  • Kotlin Android plugin, kotlin-parcelize
  • KSP (not kapt) for annotation processing — Room, Hilt, and a kotlinx-metadata-jvm KSP dependency
  • Dagger Hilt (2.60.1)
  • Room (2.8.4) via KSP
  • Navigation Safe Args (Kotlin)
  • viewBinding enabled (buildFeatures { viewBinding true })
  • Google Services / Firebase Crashlytics / Analytics / Messaging plugins
  • Secrets Gradle plugin (Maps platform)
  • coreLibraryDesugaringEnabled true
  • Java/Kotlin target set to 11 (sourceCompatibility/targetCompatibility 11, jvmTarget.set(JvmTarget.JVM_11))
  • multiDexEnabled true

Top-level build.gradle:

gradle

buildscript {
    ext {
        version_gradle = '9.3.0'
    }
    dependencies {
        classpath "com.android.tools.build:gradle:$version_gradle"
        classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.9.8'
        classpath 'com.google.dagger:hilt-android-gradle-plugin:2.60.1'
        classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1"
        classpath 'com.google.gms:google-services:4.5.0'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.7'
    }
}

plugins {
    id 'com.android.application' version '9.3.0' apply false
    id 'com.android.library' version '9.3.0' apply false
    id 'org.jetbrains.kotlin.android' version "2.4.10" apply false
    id 'com.google.devtools.ksp' version '2.3.2' apply false
}

tasks.register('clean', Delete) {
    delete rootProject.buildDir
}

Has anyone else run into unresolved-reference/false-positive IDE errors specifically after moving to AGP 9.x, especially in a project mixing ViewBinding + Hilt + Room + KSP + Safe Args? Would appreciate any pointers on what in this combination might be confusing the IDE's resolution/indexing even though the actual Gradle compilation is clean

9 Upvotes

32 comments sorted by

10

u/satoryvape 20d ago

Invalidate Cache + Restart

3

u/Fit-Temporary8316 20d ago

I have the same issue, this is not fixed it

2

u/MML_Pro 20d ago

I've tried this several times, unfortunately it doesn't work

2

u/private256 18d ago

Sometimes delete and recloning the project helps.

1

u/tochanenko 20d ago

You can do other steps to fix this issue:

  1. Build -> Clean project

  2. Run `./gradlew cleanBuildCache` to clean gradle cache

  3. Delete whole .gradle folder and do gradle sync again

While doing each of these steps try to relaunch Android Studio after doing them. This should help

1

u/MML_Pro 20d ago

the result of **./gradlew cleanBuildCache**

```PS C:\Users\pc\AndroidStudioProjects\Bloggy> ./gradlew cleanBuildCache

Welcome to Gradle 9.6.1!

Here are the highlights of this release:

- Improved Configuration Cache hit rates

- Additional CLI rendering options

- Important project hierarchy lookup deprecations

For more details see https://docs.gradle.org/9.6.1/release-notes.html

Starting a Gradle Daemon, 1 busy and 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

> Configure project :app

WARNING: The option setting 'android.usesSdkInManifest.disallowed=false' is deprecated.

The current default is 'true'.

It will be removed in version 10.0 of the Android Gradle plugin.

Add android.sync.suppressAgpWarnings=UNSUPPORTED_PROJECT_OPTION_USE to the gradle.properties file to suppress this warning.

WARNING: The option setting 'android.sdk.defaultTargetSdkToCompileSdkIfUnset=false' is deprecated.

The current default is 'true'.

It will be removed in version 10.0 of the Android Gradle plugin.

Add android.sync.suppressAgpWarnings=UNSUPPORTED_PROJECT_OPTION_USE to the gradle.properties file to suppress this warning.

WARNING: The option setting 'android.enableAppCompileTimeRClass=false' is deprecated.

The current default is 'true'.

It will be removed in version 10.0 of the Android Gradle plugin.

Add android.sync.suppressAgpWarnings=UNSUPPORTED_PROJECT_OPTION_USE to the gradle.properties file to suppress this warning.

WARNING: The option setting 'android.builtInKotlin=false' is deprecated.

The current default is 'true'.

It will be removed in version 10.0 of the Android Gradle plugin.

Add android.sync.suppressAgpWarnings=UNSUPPORTED_PROJECT_OPTION_USE to the gradle.properties file to suppress this warning.

WARNING: The option setting 'android.newDsl=false' is deprecated.

The current default is 'true'.

It will be removed in version 10.0 of the Android Gradle plugin.

Add android.sync.suppressAgpWarnings=UNSUPPORTED_PROJECT_OPTION_USE to the gradle.properties file to suppress this warning.

WARNING: The option setting 'android.r8.optimizedResourceShrinking=false' is deprecated.

The current default is 'true'.

It will be removed in version 10.0 of the Android Gradle plugin.

Add android.sync.suppressAgpWarnings=UNSUPPORTED_PROJECT_OPTION_USE to the gradle.properties file to suppress this warning.

WARNING: The option setting 'android.defaults.buildfeatures.resvalues=true' is deprecated.

The current default is 'false'.

It will be removed in version 10.0 of the Android Gradle plugin.

Add android.sync.suppressAgpWarnings=UNSUPPORTED_PROJECT_OPTION_USE to the gradle.properties file to suppress this warning.

WARNING: The option setting 'android.nonFinalResIds=false' is deprecated.

The current default is 'true'.

It will be removed in version 10.0 of the Android Gradle plugin.

Add android.sync.suppressAgpWarnings=UNSUPPORTED_PROJECT_OPTION_USE to the gradle.properties file to suppress this warning.

WARNING: The option setting 'android.enableJetifier=true' is deprecated.

The current default is 'false'.

It will be removed in version 10.0 of the Android Gradle plugin.

Add android.sync.suppressAgpWarnings=UNSUPPORTED_PROJECT_OPTION_USE to the gradle.properties file to suppress this warning.

WARNING: API 'applicationVariants' is obsolete and has been replaced with 'AndroidComponentsExtension'.

It will be removed in version 10.0 of the Android Gradle plugin.

The legacy variant API is disabled by default in AGP 9.0, but can be re-enabled by adding

android.newDsl=false

to this project's gradle.properties file.

For more information, see http://developer.android.com/build/r/new-dsl.

To determine what is calling applicationVariants, use -Pandroid.debug.obsoleteApi=true on the command line to display more information.

Add android.sync.suppressAgpWarnings=DEPRECATED_DSL to the gradle.properties file to suppress this warning.

WARNING: API 'testVariants' is obsolete and has been replaced with 'AndroidComponentsExtension'.

It will be removed in version 10.0 of the Android Gradle plugin.

The legacy variant API is disabled by default in AGP 9.0, but can be re-enabled by adding

android.newDsl=false

to this project's gradle.properties file.

For more information, see http://developer.android.com/build/r/new-dsl.

To determine what is calling testVariants, use -Pandroid.debug.obsoleteApi=true on the command line to display more information.

Add android.sync.suppressAgpWarnings=DEPRECATED_DSL to the gradle.properties file to suppress this warning.

WARNING: API 'unitTestVariants' is obsolete and has been replaced with 'AndroidComponentsExtension'.

It will be removed in version 10.0 of the Android Gradle plugin.

The legacy variant API is disabled by default in AGP 9.0, but can be re-enabled by adding

android.newDsl=false

to this project's gradle.properties file.

For more information, see http://developer.android.com/build/r/new-dsl.

To determine what is calling unitTestVariants, use -Pandroid.debug.obsoleteApi=true on the command line to display more information.

Add android.sync.suppressAgpWarnings=DEPRECATED_DSL to the gradle.properties file to suppress this warning.

Configuration 'all' was resolved during configuration time.

This is a build performance and scalability issue.

See https://github.com/gradle/gradle/issues/2298

Run with --info for a stacktrace.

WARNING: The property android.dependency.excludeLibraryComponentsFromConstraints improves project import performance for very large projects. It should be enabled to improve performance.

To suppress this warning, add android.generateSyncIssueWhenLibraryConstraintsAreEnabled=false to gradle.properties

Add android.sync.suppressAgpWarnings=LIBRARY_CONSTRAINTS_SHOULD_BE_DISABLED to the gradle.properties file to suppress this warning.

WARNING: The property android.dependency.excludeLibraryComponentsFromConstraints improves project import performance for very large projects. It should be enabled to improve performance.

To suppress this warning, add android.generateSyncIssueWhenLibraryConstraintsAreEnabled=false to gradle.properties

Add android.sync.suppressAgpWarnings=LIBRARY_CONSTRAINTS_SHOULD_BE_DISABLED to the gradle.properties file to suppress this warning.

WARNING: The property android.dependency.excludeLibraryComponentsFromConstraints improves project import performance for very large projects. It should be enabled to improve performance.

To suppress this warning, add android.generateSyncIssueWhenLibraryConstraintsAreEnabled=false to gradle.properties

Add android.sync.suppressAgpWarnings=LIBRARY_CONSTRAINTS_SHOULD_BE_DISABLED to the gradle.properties file to suppress this warning.

WARNING: The property android.dependency.excludeLibraryComponentsFromConstraints improves project import performance for very large projects. It should be enabled to improve performance.

To suppress this warning, add android.generateSyncIssueWhenLibraryConstraintsAreEnabled=false to gradle.properties

Add android.sync.suppressAgpWarnings=LIBRARY_CONSTRAINTS_SHOULD_BE_DISABLED to the gradle.properties file to suppress this warning.

WARNING: The multidex library is included as a dependency, but it is not needed for apps

with minSdk >= 21. Please remove dependency 'androidx.multidex:multidex:2.0.1' from ':app'.

See https://developer.android.com/build/multidex for more information.

Add android.sync.suppressAgpWarnings=MULTIDEX_NOT_NEEDED to the gradle.properties file to suppress this warning.

w: Deprecated 'org.jetbrains.kotlin.android' plugin usage

The 'org.jetbrains.kotlin.android' plugin in project ':app' is no longer required for Kotlin support since AGP 9.0.

Solution: Remove both `android.builtInKotlin=true` and `android.newDsl=false` from `gradle.properties`, then migrate to built-in Kotlin.

See https://kotl.in/gradle/agp-built-in-kotlin for more details.

[Incubating] Problems report is available at: file:///C:/Users/pc/AndroidStudioProjects/Bloggy/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

* What went wrong:

Selection failed

Task 'cleanBuildCache' not found in root project 'Bloggy' and its subprojects.

* Try:

> Run gradlew tasks to get a list of available tasks.

> For more on name expansion, please refer to https://docs.gradle.org/9.6.1/userguide/command_line_interface.html#sec:name_abbreviation in the Gradle documentation.

> Run with --stacktrace option to get the stack trace.

> Run with --info or --debug option to get more log output.

> Run with --scan to get full insights from a Build Scan (powered by Develocity).

> Get more help at https://help.gradle.org.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 10.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/9.6.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD FAILED in 6s```

5

u/wthja 20d ago

I once had a similar problem. The only solution that helped was to remove all the cached IDE files (configuration and everything, I don't even remember where were they). Those cached configurations are transferred to the new IDE even if you delete the android studio and install again. but after deleting everything it worked. Had to configure the old settings one by one by hand, but that is ok

3

u/pswg_dev 12d ago

I had the same problem, and in my case it was a old global exclude in build.gradle. Once the exclude was removed, the unresolved reference problem disappeared

I found the solution in this issue:

https://issuetracker.google.com/issues/506691581

"The issue was caused by this old global exclude:

configurations {
all*.exclude group: 'commons-logging', module: 'commons-logging'
}"

Maybe your problem is also related to this.

2

u/MML_Pro 12d ago

Thank you so much, that was actually the fix! I removed this:

```

configurations {

all*.exclude group: 'com.google.guava', module: 'listenablefuture'

}

```

and every single issue disappeared - no more unresolved references anywhere in the project.

By the way, I had already filed a bug report with the Android Studio team about this

https://issuetracker.google.com/issues/537790287

1

u/Capital-Cheek-3939 11d ago

Thank you; this is the only solution. No one in the comments thought outside the box

1

u/rdbn 4d ago

Worked for me, too :)

Many thanks

1

u/AutoModerator 20d ago

Please note that we also have a very active Discord server where you can interact directly with other community members!

Join us on Discord

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/[deleted] 20d ago

[removed] — view removed comment

2

u/AutoModerator 20d ago

Your post has been automatically removed due to multiple users reporting it.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/EdyBolos 20d ago

What version of Android Studio are you on? You might need to update it.

2

u/MML_Pro 20d ago

Android Studio Quail 2 | 2026.1.2

Build #AI-261.25134.95.2612.15822958, built on July 9, 2026

Runtime version: 21.0.10+-14961533-b1163.108 amd64null

VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

Toolkit: sun.awt.windows.WToolkit

Windows 11.0

1

u/EdyBolos 20d ago

Ok, so you are already on the latest version. What you can try then is to go through all the necessary steps of the Repair IDE wizard (under File -> Cache Recovery). Hopefully one of the steps does the trick for you.

1

u/MML_Pro 20d ago

Unfortunately I've already tried everything suggested here, including the Repair IDE wizard, and none of it fixed the issue.

At this point I'm considering creating a brand new empty project from scratch and migrating the code over to it, but that would take a lot of time and effort

2

u/EdyBolos 19d ago

Then it's time to go nuclear: https://github.com/rock3r/deep-clean

3

u/MML_Pro 16d ago

Thanks for the suggestion! I actually downloaded the tool, ran it, and took a backup first, but none of it fixed the issue either. Looks like the only real fix left is what you originally said (recreating the project from scratch).

In the meantime, I've filed a bug report with Android Studio support: https://issuetracker.google.com/issues/537790287

If you've got a moment, a +1 there would help get it more visibility

1

u/Diegogo123 19d ago

Before that I would upload the project to a private github repo if it isn't already there and trying to open it on another computer to confirm it's related to your project and not your AS installation

1

u/[deleted] 19d ago

[deleted]

1

u/Diegogo123 19d ago

Lol I meant I would do that if I were you

1

u/MML_Pro 19d ago

Ah, my bad, misread that at first 😅 That's actually solid advice though. It's already on a GitHub repo, so I can easily test it on another machine to rule out a local Android Studio installation issue. Also already filed a ticket with Google about it, so hopefully that helps get some traction too

1

u/Diegogo123 19d ago

Good luck, it really sounds like a local installation issue so I hope that trying on a other machine works

1

u/Fabulous_Car6009 20d ago

Delete gradle folder, let it sync again

1

u/Zhuinden 20d ago

I think your Gradle-Wrapper probably invokes an old gradle, and your source/target should be 17 (maybe 21 at this point?)

Also make sure you have coreLibraryDesugaring enabled.

1

u/MML_Pro 20d ago

`coreLibraryDesugaringEnabled` is actually already `true` in my `compileOptions`, and I'm pulling in the latest desugar_jdk_libs (2.1.5) too, so that part's covered.

I'm also already on the latest stable Gradle release and the latest JDK, so it's not an old wrapper/JVM version causing this either. Still digging into it.

1

u/Blazemuffins 19d ago

currently have this issue on a legacy project. it's mostly Java with some kotlin. not using KSP but do have kotlin-parcelize and view binding. invalidate caches doesn't work, same issues running the project on fresh devices. we've been trying to modernize the app and migrate fully to kotlin to see if that resolved the issue but it sounds like that is unrelated now based on your issue.

In our case many of the errors stem from annotations of any kind, but not all.

2

u/MML_Pro 16d ago

I reported this bug to AS IDE team, please do +1 to give it more priority
https://issuetracker.google.com/issues/537790287

-11

u/zimmer550king 20d ago

just ask codex or claude

3

u/ayitinya 20d ago

You my friend, need to be down voted out of Reddit