I'm using Android Studio 3.0 Preview to start new Kotlin project. As I try to add dependencies in build.gradle
I saw implementation
scope instead of usual compile
.
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:25.3.1'
testImplementation 'junit:junit:4.12'
There's also androidTestImplementation
and testImplementation
scope.
In the end, I add compile
to add third party dependencies and it works.
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
So my questions are..
implementation
, androidTestImplementation
, and testImplementation
scope? compile
, testCompile
, and androidTestCompile
?Edit: My bad, this question is not Kotlin specific. It's the new Android Gradle Plugin configuration.
Implementation dependencies : The references used in the relations between components are typed using concrete classes or abstract classes. Interface dependencies: The references used in the relations between components are typed using only interfaces.
Fortunately, the implementation dependency configuration provides the same functionality as compile. You should always use implementation rather than compile for dependencies, as compile is now deprecated or removed in the case of Gradle 7+.
Dependencies refer to the things that supports in building your project, such as required JAR file from other projects and external JARs like JDBC JAR or Eh-cache JAR in the class path. Publications means the outcomes of the project, such as test class files, build files and war files.
Dependency on a Kotlin library A dependency on a standard library ( stdlib ) in each source set is added automatically. The version of the standard library is the same as the version of the kotlin-multiplatform plugin.
This is not specific to Kotlin, but has to do with the new Gradle plugin for Android.
compile
, provided
and apk
are now deprecated.
Use implementation
or api
instead of compile
, compileOnly
instead of provided
, and runtimeOnly
instead of apk
.
The reason for this is to speed up multi-module builds. Given module A
which depends on module B
which in turn depends on module C
, a change in module C
would trigger a recompile of module A
as well. If A
does not use C
directly, there is no need for A
to recompile when C
changes.
The implementation
configuration ensures exactly this: if you specify implementation project(':C')
in B
, you cannot access C
from A
and you avoid building unnecessary modules. In a large multi-module project this can save a lot of time.
See Migrate to the new Gradle plugin for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With