I have an Android app (app
module) and an Android library module (lib
module), each being a separate Android Studio project, but the app project added lib
in as a module dependency in its project.
The lib
uses JetBrain's Dokka to generate HTML documentation, and it needs the Dokka Android Gradle plugin, which is defined in its own project's top-level build.gradle
:
buildscript {
dependencies {
// ...
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.18"
}
}
And in the lib
module's build.gradle
I had to add the following
apply plugin: 'org.jetbrains.dokka-android'
android {
// ...
dokka { /* my Dokka config */ }
}
So right now the lib
project works and builds fine and I'm able to generate documentation HTMLs using Dokka.
However, my app project's Gradle sync now fails because it says "Plugin with id org.jetbrains.dokka-android not found". If I add the classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.18"
to my app project's top-level build.gradle
then it works fine.
My question is, how do I tell the main (app) project that the classpath dependency for Dokka has already been declared in the lib
module's top-level build.gradle
? Or is there a way to specify this dependency for just the lib
module? I also think it's weird if I have multiple apps using my lib
module and they would need to add this classpath dependency to be able to build their apps.
Much thanks.
You can just add this part in your lib/build.gradle
removing from the top-level file.
buildscript {
//
dependencies {
classpath 'org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.18'
}
}
It happens because you are importing this lib as an external module and you are running some tasks (for example a build
task) in the lib
module.
You can avoid it: