Does anyone know what needs to be added to `build....
# dagger
n
Does anyone know what needs to be added to
build.gradle
file to enable kapt to work properly when using JDK 15 to build? I keep getting this error `package javax.annotation.processing does not exist import javax.annotation.processing.Generated`whenever I try to build. My config is the following:
Copy code
plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
}

kapt {
    javacOptions {
        option("-source", "8")
        option("-target", "8")
    }
}

android {
    compileSdkVersion 30
    defaultConfig {
        applicationId "com.ndoglio.daggerkapt"
        minSdkVersion 23
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), '<http://proguard-rules.pro|proguard-rules.pro>'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'

    implementation 'com.google.dagger:dagger:2.30.1'
    kapt 'com.google.dagger:dagger-compiler:2.30.1'
}
r
are you really need to run with JDK 15? use jdk 11 from latest artic fox would be enough @Nicholas Doglio
j
There should be no need to use such an old version. I use 15 as my default and it works everywhere. What version of Kotlin?
r
@jw i do remember having similar issue on jdk 15, in that time i was switch back to 8
j
Recent versions of Kotlin contain fixes for the endless pain that is kapt. Make sure you're on 1.4.20
r
ah that make sense 👍
n
@jw I’m using 1.4.21 when I’m seeing the issue above
j
What's the name of the file that errors?
n
DaggerAppComponent
the above file is just a simple project to reproduce the error, I just added a
AppComponent
and tried to build it
👍 1
j
I think you need to add this dependency implementation "org.glassfish.jaxbjaxb runtime2.3.3"
Read this readme for more info https://github.com/alvr/alpine-android
n
Update for anyone curious about this: This issue seems to be the single dash when configuring the
kapt
extension. Changing it to the following with two dashes fixes the issue and builds correctly.
Copy code
kapt {
    javacOptions {
        option("--source", "8")
        option("--target", "8")
    }
}