android – How to use gradle BoM with annotation processor?-ThrowExceptions

Exception or error:

I’m trying to define all my dependencies in a bill of materials (BoM) platform module so the other modules in my multi-module project can use the same versions. All works fine except the kapt dependencies. In those I get this error:

Could not determine the dependencies of task ':app:kaptDebugKotlin'.
> Could not resolve all task dependencies for configuration ':app:kapt'.
   > Could not find com.google.dagger:dagger-compiler:.
     Required by:
         project :app

For example with this platform (:bom) module:

plugins {
  id 'java-platform'
}
dependencies {
  constraints {
    api 'com.google.dagger:dagger:2.25.2'
    api 'com.google.dagger:dagger-compiler:2.25.2'
  }
}

I’m getting that error when I use it like this in the app module:

dependencies {
  implementation platform(project(':bom'))
  implementation 'com.google.dagger:dagger'
  kapt 'com.google.dagger:dagger-compiler'
  // ...
}

I’m getting the same error if I use annotationProcessor. If I set the version like kapt 'com.google.dagger:dagger-compiler:2.25.2' all works.

What am I doing wrong? Can I use BoM for kapt or annotationProcessor?

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *