2

I tried upgrading my app for supporting API 29, and it works when I just upgrade the compileSdkVersion and targetSdkVersion to 29. However, as soon as I change my buildTools Version to 29.0.2, I get Unresolved reference errors for my files that I know are right (The errors are in one of my user files, not an external library). I know that it is right because when I pull the same code (and branch) on my mac, it works perfectly with the 29.0.2 buildToolsVersion.

I tried a bunch of things based on other stackoverflow posts like checking my gradle version, kotlin plugins, etc.

As an example: Android Studio 3.1: Erroneous unresolved references in editor

(Note that the difference between mine and the one shown in the link above is that there is no red highlights for any of those unresolved errors and the file does not have any red squiggly underline. I would not know that there was any error in the file without looking at the build output.)

Things I tried (that does not work):

  • Clean project and rebuild
  • Invalidating cache and restart
  • deleting .idea folder
  • Resyncing gradle files
  • Reinstalling android studio and cloning repo again
  • Placing "apply plugin: kotlin-android-extensions" in various places

Within my build.gradle, I have:

buildscript {
    ext.versions = [
                .
                .
                .
                buildGradle        : "3.5.0"
                kotlin             : "1.3.31"
                kotlinGradlePlugin : "1.3.50"
                kotlinReflect      : "1.3.50"
                kotlinStdLib       : "1.3.50"
                .
                .
                .
    ]
}

In my common.gradle, I have:

apply plugin: 'kotlin-android'

android {
    compileSdkVersion 29
    buildToolsVersion '29.0.2'

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 29
        .
        .
        .
    }
}

Also note that unfortunately this project is not open-source, so I can't show too much of the code or the project. But it is a hybrid project (contains both kotlin and java code).

Java Version: 1.8
Kotlin JVM version: 1.6

Any suggestions on what I could try would be appreciated cause I am really stuck now (and could not find any difference in configs between mac and this one).

blankface
  • 41
  • 1

1 Answers1

0

As an answer to myself, not exactly sure why this was happening, but I suspect it has something to do with one of the files being kotlin and the other one being java. I was trying to import java file into kotlin file as dependency, and this caused the unresolved errors. Not sure why it was not causing the same error with other machines and not sure why it was struggling only with this file, when I have other kotlin files that also import java files. My solution was to convert that java file to kotlin and everything worked fine after that.

blankface
  • 41
  • 1