{"id":3729,"url":"https://github.com/Kotlin/anko","last_synced_at":"2025-08-03T23:33:53.593Z","repository":{"id":20899225,"uuid":"24186761","full_name":"Kotlin/anko","owner":"Kotlin","description":"Pleasant Android application development","archived":true,"fork":false,"pushed_at":"2019-12-05T08:59:41.000Z","size":15239,"stargazers_count":15875,"open_issues_count":243,"forks_count":1290,"subscribers_count":531,"default_branch":"master","last_synced_at":"2024-12-04T21:38:15.239Z","etag":null,"topics":["android","kotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kotlin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-18T12:12:23.000Z","updated_at":"2024-12-04T18:51:39.000Z","dependencies_parsed_at":"2022-07-14T22:30:44.231Z","dependency_job_id":null,"html_url":"https://github.com/Kotlin/anko","commit_stats":null,"previous_names":["jetbrains/anko"],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fanko","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fanko/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fanko/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fanko/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kotlin","download_url":"https://codeload.github.com/Kotlin/anko/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228576887,"owners_count":17939645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","kotlin"],"created_at":"2024-01-05T20:16:49.764Z","updated_at":"2024-12-07T07:30:34.804Z","avatar_url":"https://github.com/Kotlin.png","language":"Kotlin","funding_links":[],"categories":["Kotlin","Libraries","[Programming]","Development Alternatives","Android 应用","\u003ca name=\"android\"\u003e\u003c/a\u003eAndroid \u003csup\u003e[Back ⇈](#android-category)\u003c/sup\u003e","开源库","\u003ca name=\"toolbox\"\u003e\u003c/a\u003eToolbox \u003csup\u003e[Back ⇈](#contents)\u003c/sup\u003e","[](https://github.com/JStumpp/awesome-android/blob/master/readme.md#development-alternatives)非Java开发安卓应用"],"sub_categories":["Android","[Programming] - [Kotlin]","Kotlin","网络服务_其他","\u003ca name=\"android-libraries\"\u003e\u003c/a\u003eLibraries \u003csup\u003e[Back ⇈](#android-libraries-subcategory)\u003c/sup\u003e","DSL","[](https://github.com/JStumpp/awesome-android/blob/master/readme.md#kotlin)Kotlin"],"readme":"[![obsolete JetBrains project](https://jb.gg/badges/obsolete.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)\n[![Download](https://api.bintray.com/packages/jetbrains/anko/anko/images/download.svg) ](https://bintray.com/jetbrains/anko/anko/_latestVersion)\n[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)\n\n\u003cimg src=\"doc/logo.png\" alt=\"Anko logo\" height=\"101\" width=\"220\" /\u003e\n\n:warning: Anko is deprecated. Please see [this page](/GOODBYE.md) for more information.\n\n* * *\n\nAnko is a [Kotlin](https://www.kotlinlang.org/) library which makes Android application development faster and easier. It makes your code clean and easy to read, and lets you forget about rough edges of the Android SDK for Java.\n\nAnko consists of several parts:\n\n* *Anko Commons*: a lightweight library full of helpers for intents, dialogs, logging and so on;\n* *Anko Layouts*: a fast and type-safe way to write dynamic Android layouts;\n* *Anko SQLite*: a query DSL and parser collection for Android SQLite;\n* *Anko Coroutines*: utilities based on the [kotlinx.coroutines](https://github.com/Kotlin/kotlinx.coroutines) library.\n\n## Anko Commons\n\n*Anko Commons* is a \"toolbox\" for Kotlin Android developer. The library contains a lot of helpers for Android SDK, including, but not limited to:\n\n* Intents ([wiki](https://github.com/Kotlin/anko/wiki/Anko-Commons-–-Intents));\n* Dialogs and toasts ([wiki](https://github.com/Kotlin/anko/wiki/Anko-Commons-–-Dialogs));\n* Logging ([wiki](https://github.com/Kotlin/anko/wiki/Anko-Commons-–-Logging));\n* Resources and dimensions ([wiki](https://github.com/Kotlin/anko/wiki/Anko-Commons-–-Misc)).\n\n## Anko Layouts ([wiki](https://github.com/Kotlin/anko/wiki/Anko-Layouts))\n\n*Anko Layouts* is a DSL for writing dynamic Android layouts. Here is a simple UI written with Anko DSL:\n\n```kotlin\nverticalLayout {\n    val name = editText()\n    button(\"Say Hello\") {\n        onClick { toast(\"Hello, ${name.text}!\") }\n    }\n}\n```\n\nThe code above creates a button inside a `LinearLayout` and attaches an `OnClickListener` to that button. Moreover, `onClick` accepts a [`suspend` lambda](https://kotlinlang.org/docs/reference/coroutines.html), so you can write your asynchronous code right inside the listener!\n\nNote that this is the complete layout code. No XML is required!\n\nAnko has a [DSL for ConstraintLayout](https://github.com/Kotlin/anko/wiki/ConstraintLayout) since v0.10.4\n\n\u003cimg src=\"doc/helloworld.png\" alt=\"Hello world\" height=\"90\" width=\"373\" /\u003e\n\nThere is also a [plugin](https://github.com/Kotlin/anko/wiki/Anko-Layouts#anko-support-plugin) for Android Studio that supports previewing Anko DSL layouts.\n\n## Anko SQLite ([wiki](https://github.com/Kotlin/anko/wiki/Anko-SQLite))\n\nHave you ever been tired of parsing SQLite query results using Android cursors? *Anko SQLite* provides lots of helpers to simplify working with SQLite databases.\n\nFor example, here is how you can fetch the list of users with a particular name:\n\n```kotlin\nfun getUsers(db: ManagedSQLiteOpenHelper): List\u003cUser\u003e = db.use {\n    db.select(\"Users\")\n            .whereSimple(\"family_name = ?\", \"John\")\n            .doExec()\n            .parseList(UserParser)\n}\n```\n\n## Anko Coroutines ([wiki](https://github.com/Kotlin/anko/wiki/Anko-Coroutines))\n\n*Anko Coroutines* is based on the [`kotlinx.coroutines`](https://github.com/kotlin/kotlinx.coroutines) library and provides:\n\n* [`bg()`](https://github.com/Kotlin/anko/wiki/Anko-Coroutines#bg) function that executes your code in a common pool.\n* [`asReference()`](https://github.com/Kotlin/anko/wiki/Anko-Coroutines#asreference) function which creates a weak reference wrapper. By default, a coroutine holds references to captured objects until it is finished or canceled. If your asynchronous framework does not support cancellation, the values you use inside the asynchronous block can be leaked. `asReference()` protects you from this.\n\n## Using Anko\n\n### Gradle-based project\n\nAnko has a meta-dependency which plugs in all available features (including Commons, Layouts, SQLite) into your project at once:\n\n```gradle\ndependencies {\n    implementation \"org.jetbrains.anko:anko:$anko_version\"\n}\n```\nMake sure that you have the ```$anko_version``` settled in your gradle file at the project level:\n\n```\next.anko_version='0.10.8'\n```\n\nIf you only need some of the features, you can reference any of Anko's parts:\n\n```gradle\ndependencies {\n    // Anko Commons\n    implementation \"org.jetbrains.anko:anko-commons:$anko_version\"\n\n    // Anko Layouts\n    implementation \"org.jetbrains.anko:anko-sdk25:$anko_version\" // sdk15, sdk19, sdk21, sdk23 are also available\n    implementation \"org.jetbrains.anko:anko-appcompat-v7:$anko_version\"\n\n    // Coroutine listeners for Anko Layouts\n    implementation \"org.jetbrains.anko:anko-sdk25-coroutines:$anko_version\"\n    implementation \"org.jetbrains.anko:anko-appcompat-v7-coroutines:$anko_version\"\n\n    // Anko SQLite\n    implementation \"org.jetbrains.anko:anko-sqlite:$anko_version\"\n}\n```\n\nThere are also a number of artifacts for the Android support libraries:\n\n```gradle\ndependencies {\n    // Appcompat-v7 (only Anko Commons)\n    implementation \"org.jetbrains.anko:anko-appcompat-v7-commons:$anko_version\"\n\n    // Appcompat-v7 (Anko Layouts)\n    implementation \"org.jetbrains.anko:anko-appcompat-v7:$anko_version\"\n    implementation \"org.jetbrains.anko:anko-coroutines:$anko_version\"\n\n    // CardView-v7\n    implementation \"org.jetbrains.anko:anko-cardview-v7:$anko_version\"\n\n    // Design\n    implementation \"org.jetbrains.anko:anko-design:$anko_version\"\n    implementation \"org.jetbrains.anko:anko-design-coroutines:$anko_version\"\n\n    // GridLayout-v7\n    implementation \"org.jetbrains.anko:anko-gridlayout-v7:$anko_version\"\n\n    // Percent\n    implementation \"org.jetbrains.anko:anko-percent:$anko_version\"\n\n    // RecyclerView-v7\n    implementation \"org.jetbrains.anko:anko-recyclerview-v7:$anko_version\"\n    implementation \"org.jetbrains.anko:anko-recyclerview-v7-coroutines:$anko_version\"\n\n    // Support-v4 (only Anko Commons)\n    implementation \"org.jetbrains.anko:anko-support-v4-commons:$anko_version\"\n\n    // Support-v4 (Anko Layouts)\n    implementation \"org.jetbrains.anko:anko-support-v4:$anko_version\"\n\n    // ConstraintLayout\n    implementation \"org.jetbrains.anko:anko-constraint-layout:$anko_version\"\n}\n```\n\nThere is an [example project](https://github.com/kotlin/anko-example) showing how to include Anko library into your Android Gradle project.\n\n### IntelliJ IDEA project\n\nIf your project is not based on Gradle, just attach the required JARs from the [jcenter repository](https://jcenter.bintray.com/org/jetbrains/anko/) as the library dependencies and that's it.\n\n## Contributing\n\nThe best way to submit a patch is to send us a [pull request](https://help.github.com/articles/about-pull-requests/). Before submitting the pull request, make sure all existing tests are passing, and add the new test if it is required.\n\nIf you want to add new functionality, please file a new *proposal* issue first to make sure that it is not in progress already. If you have any questions, feel free to create a *question* issue.\n\nInstructions for building Anko are available in the [Wiki](https://github.com/Kotlin/anko/wiki/Building-Anko).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKotlin%2Fanko","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKotlin%2Fanko","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKotlin%2Fanko/lists"}