I am trying to use Anko with my Android Kotlin Project. I have added the line to my dependencies / gradle module file as follows:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "org.jetbrains.anko:anko:$anko_version"
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support:support-vector-drawable:26.+'
compile 'com.android.support:support-v4:26.+'
testCompile 'junit:junit:4.12'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
But I get the following error when trying to do a gradle sync:
Error:(36, 0) Could not get unknown property 'anko_version' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. Open File
How can I properly incorporate Anko in my project?
For reference, I am using Android Studio 2.0.
Add anko_version
in ext
block above the dependencies
block:
ext {
anko_version = '0.10.1'
}
Another option, as Naetmul suggested in the comments, is to replace the $anko_version
with 0.10.1