I'd read the documentation but I'm not able to understand how to create a working example to understand better their differences.
And ofc I've created a playground project to check what happens when I use one or another.
app.gradle
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$rootProject.kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
compileOnly project(":compileonlylibrary")
runtimeOnly project(":runtimeonlylibrary")
}
MainActivity.kt
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
FooCompile() // this crash in runtime
BarRuntime() // this doesn't compiles obviously
}
}
// FooCompile belongs to compileonlylibrary
// BarRuntime belongs to runtimeonlylibrary
And that's it, I'm stuck here, I'm not able to create a proper example in order to improve my knowledge of Gradle configurations.
Could someone give me a hand? I can provide more details if needed.