Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not get unknown property 'anko_version' for object of type...?

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.

like image 675
arcade16 Avatar asked Aug 23 '17 04:08

arcade16


2 Answers

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

like image 176
Bob Avatar answered Nov 18 '22 15:11

Bob


You can define it in your project level build.gradle file.

enter image description here

OR

You can replace with current version which is 0.10.1 (on 1 Sep 2017)

like image 38
Pravin Londhe Avatar answered Nov 18 '22 14:11

Pravin Londhe