Search code examples
androidandroid-gradle-pluginkotlinkapt

Kotlin Kapt failing - only sees android api level 1 sources


I'm seeing some weird behavior that causes :app:kaptQaDebugKotlin to fail when attempting to upgrade to android gradle plugin 3.0.

  • method annotated with @TargetApi(VERSION_CODES.KITKAT) fails with cannot find symbol (VERSION_CODES.KITKAT)
  • ...but VERSION_CODES.KITKAT when used inline with a method is found
  • can't find symbol DialogInterface.OnShowListener (added in API level 8)
  • ..but DialogInteface.OnClickListener is found (added in API level 1)
  • cannot find symbol Application.ActivityLifecycleCallbacks (added in api level 14)
  • note: Android Studio is able to see the source of all these cannot find symbol classes (cmd + B works)

Versions

  • compileSdkVersion: 25
  • buildTools: 26.0.2
  • Kotlin version: 1.1.51
  • AGP: 3.0.0
  • gradle wrapper: 4.3
  • Support lib: 24.2.1 (would be difficult to upgrade this too, but I did try 25.4.0 and still no luck)
  • Dagger: 2.0.2 (stuck on this old version, can't upgrade unfortunately)
  • use AGP 3.0.0 java 8 desugar feature
  • using kotlin-kapt plugin. autovalue classes are correctly generated.

Any idea what's going on? It looks like the kapt task is somehow using android api level 1 sources, and I'm not sure how to troubleshoot that


Solution

  • Per @pentarex

    error was coming from external library logback-android-classic, i had to exclude group: 'com.google.android', module: 'android

    implementation(libs.logbackAndroidClassic){
        exclude group: 'com.google.android', module: 'android'
    }