Closed cypressious closed 8 years ago
I agree. Right now if I want to use Anko for the first time I don't know which modules (or packages) need to be added to my project in order to experiment with the different features outlined in the README file.
As an example, I just added the following dependencies to an Android project:
compile 'org.jetbrains.anko:anko-common:0.7'
compile 'org.jetbrains.anko:anko-appcompat-v7:0.7'
In one of my activities I'm trying to replace Butterknife which uses this syntax:
val artistBio: TextView by bindView(R.id.artistBio)
With Anko's syntax
val artistBio = find<TextView>(R.id.artistBio)
I'm using Intellij 15 with ext.kotlin_version = '0.13.1513'. The IDE does not recognize the "find" keyword and I get the following build error if I attempt to build the project:
Error:(32, 21) Gradle: Unresolved reference: anko
Error:(44, 20) Gradle: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
kotlin.inline public fun <T> kotlin.Array<out android.widget.TextView>.find(predicate: (android.widget.TextView) -> kotlin.Boolean): android.widget.TextView? defined in kotlin
kotlin.inline public fun kotlin.BooleanArray.find(predicate: (kotlin.Boolean) -> kotlin.Boolean): kotlin.Boolean? defined in kotlin
kotlin.inline public fun kotlin.ByteArray.find(predicate: (kotlin.Byte) -> kotlin.Boolean): kotlin.Byte? defined in kotlin
kotlin.inline public fun kotlin.CharArray.find(predicate: (kotlin.Char) -> kotlin.Boolean): kotlin.Char? defined in kotlin
kotlin.inline public fun kotlin.DoubleArray.find(predicate: (kotlin.Double) -> kotlin.Boolean): kotlin.Double? defined in kotlin
kotlin.inline public fun kotlin.FloatArray.find(predicate: (kotlin.Float) -> kotlin.Boolean): kotlin.Float? defined in kotlin
kotlin.inline public fun kotlin.IntArray.find(predicate: (kotlin.Int) -> kotlin.Boolean): kotlin.Int? defined in kotlin
kotlin.inline public fun <T> kotlin.Iterable<android.widget.TextView>.find(predicate: (android.widget.TextView) -> kotlin.Boolean): android.widget.TextView? defined in kotlin
kotlin.inline public fun kotlin.LongArray.find(predicate: (kotlin.Long) -> kotlin.Boolean): kotlin.Long? defined in kotlin
kotlin.inline public fun <T> kotlin.Sequence<android.widget.TextView>.find(predicate: (android.widget.TextView) -> kotlin.Boolean): android.widget.TextView? defined in kotlin
kotlin.inline public fun kotlin.ShortArray.find(predicate: (kotlin.Short) -> kotlin.Boolean): kotlin.Short? defined in kotlin
kotlin.inline public fun kotlin.String.find(predicate: (kotlin.Char) -> kotlin.Boolean): kotlin.Char? defined in kotlin
+1 for improvements documents. For me know anko looks like an showcase. I maybe will use in the future, until then, I wait for better docs, API links :)
@cavega you need an anko-sdk lib. I'm not sure which version to choose, you should always compile with the latest and target whichever minimal version you want, so I guess that you need to specify this minimal version here? That's what I do.
Then for each support lib you use, you add the associated anko lib. This is what I have:
buildscript {
ext.kotlin_version = '0.13.1514'
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId 'fr.ribesg.android.xxx'
minSdkVersion 15 // Min SDK version is 15
targetSdkVersion 23
versionName '0.0.1'
versionCode 1
}
buildTypes {
release {
minifyEnabled false
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// Note the used support libs
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'org.jetbrains.anko:anko-sdk15:0.7' // So here it's 15 too
// Same Anko libs than support libs
compile 'org.jetbrains.anko:anko-appcompat-v7:0.7'
compile 'org.jetbrains.anko:anko-design:0.7'
compile 'org.jetbrains.anko:anko-recyclerview-v7:0.7'
}
Support libs ARE split into multiple different packages. It seems logical for Anko to follow the same, to get only what matches what you already have.
@Ribesg Thanks for the response. After some experimentation with the different modules it looks like the "find" view binding feature is part of the main Anko module (I used "org.jetbrains.anko:anko-sdk15:0.7" for my minSdk 15 project).
The original comment by @cypressious still stands: what can the "core", "recyclerview", "appcompat", etc modules be used for? A summary in the README would be nice.
There you have a dependencies tree
It was useful for me to check.
Also looks like recyclerview is misspelled as "recycleriew"
https://bintray.com/jetbrains/anko/anko/anko-recycleriew-v7-0.8.3/view
Hi folks, the issue was closed, but I still cannot find the difference between anko sdk15, sdk19, sdk21, sdk23, sdk25.
If i have the min target of android 19 in my project I have to add all the anko-sdk libraries?
@amadeu01 nope, you match your minSDK with one of the SDKs. Think of them as they would have + sign e.g. sdk19+
If you would have minSDK=17, sdk19 wouldn't be sufficient and you would need to go lower to sdk15
On a side: I am personally moving away from Anko since it doesn't seem to be developed much any longer. I don't know what is your use case but maybe consider other options like Android KTX.
We now have all of the following versions of Anko:
anko-support-v4-0.7 anko-sdk23-0.7 anko-sdk21-0.7 anko-sdk19-0.7 anko-sdk15-0.7 anko-recyclerview-v7-0.7 anko-percent-0.7 anko-gridlayout-v7-0.7 anko-design-0.7 anko-common-0.7 anko-cardview-v7-0.7 anko-appcompat-v7-0.7
Please clarify, how the versions differ and which to use in your project.