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

4

5

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.

Consumptive answered 23/8, 2017 at 4:5 Comment(1)
Just replace $anko_version with 0.10.1.Padget
B
7

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

Busyness answered 23/8, 2017 at 4:15 Comment(0)
S
2

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)

Straightway answered 23/8, 2017 at 4:34 Comment(0)
A
0

This is how I do it and it works great:

  1. Open your project gradle.
  2. Add a ext block within the buildscript block.
  3. Add your versions properties.

enter image description here

Within your app gradle, set your versions like so:

enter image description here

Ayrshire answered 21/1, 2019 at 19:5 Comment(0)
F
0

Use this

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

Don't use this

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

and don't use this

implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
Fluidextract answered 19/3, 2021 at 15:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.