Kotlin 中文文档
转载地址:http://www.tuicool.com/articles/faqyMzE
gitbook 墙内访问速度很糟糕 现在有了 墙内地址 啦 :)
国内服务器由 掘金 赞助
稀土掘金:挖掘最优质的互联网技术 / 联合编辑每日精选内容 / 移动端优质阅读体验
本书源码在github
记得要点 star star star
发现有翻译的不好的或者错误欢迎到 github 提issue
号外 号外 Kotlin 1.0 正式发布
Kotlin 是一个实用性很强的语言,专注于互通,安全,简洁,工具健全...
无缝支持 Java+Kotlin 项目,可以更少的使用样版代码,确保类型安全。
还换了logo :)
Kotlin LOC (软件规模代码行) 如下图

近期我会重新读一遍 Kotlin 官方文档 并对现在的这份文档进行更新(又立 flag 了) -- 2016.2.16
看示例:
- // Top-level build file where you can add configuration options common to all sub-projects/modules.
- buildscript {
- ext.kotlin_version = '1.0.6'
- repositories {
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:2.0.0'
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
- classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
- }
- }
- allprojects {
- repositories {
- jcenter()
- }
添加了版本号以及要使用的俩个依赖,如果需要还可以导入其他的依赖。
在app的目录(也就是你android代码目录)的build.gradle文件中添加简单的设置就好
看示例:
- buildscript {
- repositories {
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:2.0.0'
- }
- }
- def getDate() {
- return Calendar.getInstance().getTimeInMillis();
- }
- allprojects {
- repositories {
- jcenter()
- }
- }
- apply plugin: 'com.android.application'
- apply plugin: 'kotlin-android'
- dependencies {
- compile 'com.android.support:support-v4:23.1.1'
- compile 'com.android.support:appcompat-v7:23.1.1'
- compile 'com.android.support:design:23.1.1'
- compile 'com.android.support:preference-v7:23.1.1'
- compile 'org.apache.commons:commons-compress:1.10'
- compile 'commons-net:commons-net:3.3'
- compile 'com.github.zafarkhaja:java-semver:0.9.0'
- compile 'org.unbescape:unbescape:1.1.1.RELEASE'
- compile 'org.msgpack:msgpack:0.6.12'
- compile 'com.googlecode.juniversalchardet:juniversalchardet:1.0.3'
- compile 'org.tukaani:xz:1.5'
- compile 'ch.acra:acra:4.6.2'
- testCompile 'junit:junit:4.12'
- compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
- }
- android {
- compileSdkVersion 23
- buildToolsVersion '23.0.2'
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_7
- targetCompatibility JavaVersion.VERSION_1_7
- }
- packagingOptions {
- exclude 'META-INF/LICENSE.txt'
- exclude 'META-INF/NOTICE.txt'
- }
- defaultConfig {
- minSdkVersion 9
- targetSdkVersion 22
- versionCode 4
- versionName "1.7.0-unstable"
- if(System.getenv("NIGHTLY_BUILD")) {
- versionName += "+" + System.getenv("NIGHTLY_BUILD_COMMIT").substring(0, 7)
- }
- }
- lintOptions {
- if (System.getenv("NIGHTLY_BUILD")) {
- checkReleaseBuilds false
- }
- abortOnError false
- }
- signingConfigs {
- release {
- if (System.getenv("KEYSTORE_FILE") != null) {
- storeFile = file(System.getenv("KEYSTORE_FILE"))
- storePassword = System.getenv("KEYSTORE_PWD")
- keyAlias = System.getenv("KEYSTORE_ALIAS")
- keyPassword = System.getenv("KEYSTORE_ALIAS_PWD")
- }
- return true
- }
- }
- buildTypes {
- debug {
- buildConfigField "java.util.Date", "BUILD_TIME", "new java.util.Date(" + getDate() + "L)"
- buildConfigField "String", "BUILD_NAME", "\"" + System.getenv("USER") + "\"";
- minifyEnabled false
- shrinkResources false
- debuggable true
- jniDebuggable true
- zipAlignEnabled true
- multiDexEnabled true
- }
- release {
- buildConfigField "java.util.Date", "BUILD_TIME", "new java.util.Date(" + getDate() + "L)"
- buildConfigField "String", "BUILD_NAME", "\"" + System.getenv("USER") + "\"";
- if (System.getenv("KEYSTORE_FILE") != null) {
- signingConfig signingConfigs.release
- }
- multiDexEnabled true
- return true
- }
- }
- sourceSets {
- main.java.srcDirs += 'src/main/kotlin'
- }
- }
- repositories {
- mavenCentral()
- }
主要添加了有3个地方:
1、
- <span style="white-space:pre"> </span>apply plugin: 'kotlin-android'
2、
- <span style="white-space:pre"> </span>compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
3、
- android{
- ......
- sourceSets {
- main.java.srcDirs += 'src/main/kotlin'
- }
- }
这样就可以正常使用了。
如果出现
Execution failed for task ':app:clean'.
> Unable to delete file: C:\Users\User\KotlinGameEngine\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.0.1\jars\classes.jar
类似这样的问题,那么只要在app目录下的build.gradle文件中添加task:
- task clean(type: Exec) {
- ext.lockhunter = '\"C:\\LockHunter.exe\"'
- def buildDir = file(new File("build"))
- commandLine 'cmd', "$lockhunter", '/delete', '/silent', buildDir
- }
如果出现Unresolved reference: kotlinx这样的问题,那么需要在app目录下的build.gradle文件中添加:
apply plugin: 'kotlin-android-extensions'
以及要确保classpath配置了classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
- 顶
- 1
- 踩
- 1
- 个人资料
Kotlin 中文文档的更多相关文章
- Reactor3 中文文档(用户手册)
文章很长,建议收藏起来,慢慢读! 疯狂创客圈为小伙伴奉上以下珍贵的学习资源: 疯狂创客圈 经典图书 : <Netty Zookeeper Redis 高并发实战> 面试必备 + 大厂必备 ...
- Phoenix综述(史上最全Phoenix中文文档)
个人主页:http://www.linbingdong.com 简书地址:http://www.jianshu.com/users/6cb45a00b49c/latest_articles 网上关于P ...
- Chart.js中文文档-雷达图
雷达图或蛛网图(Radar chart) 简介 A radar chart is a way of showing multiple data points and the variation bet ...
- Knockout中文开发指南(完整版API中文文档) 目录索引
a, .tree li > span { padding: 4pt; border-radius: 4px; } .tree li a { color:#46cfb0; text-decorat ...
- ReactNative官方中文文档0.21
整理了一份ReactNative0.21中文文档,提供给需要的reactnative爱好者.ReactNative0.21中文文档.chm 百度盘下载:ReactNative0.21中文文档 来源: ...
- java中文文档官方下载
一直在寻找它,今天无意之间终于发现它了! http://download.oracle.com/technetwork/java/javase/6/docs/zh/api/overview-summa ...
- Spring中文文档
前一段时间翻译了Jetty的一部分文档,感觉对阅读英文没有大的提高(*^-^*),毕竟Jetty的受众面还是比较小的,而且翻译过程中发现Jetty的文档写的不是很好,所以呢翻译的兴趣慢慢就不大了,只能 ...
- jQuery 3.1 API中文文档
jQuery 3.1 API中文文档 一.核心 1.1 核心函数 jQuery([selector,[context]]) 接收一个包含 CSS 选择器的字符串,然后用这个字符串去匹配一组元素. jQ ...
- jQuery EasyUI API 中文文档 - ComboGrid 组合表格
jQuery EasyUI API 中文文档 - ComboGrid 组合表格,需要的朋友可以参考下. 扩展自 $.fn.combo.defaults 和 $.fn.datagrid.defaults ...
随机推荐
- BZOJ 3667 Pollard-rho &Miller-Rabin
论O(1)快速乘和O(logn)快速乘的差距-. //By SiriusRen #include <cstdio> #include <algorithm> using nam ...
- Request.QueryString["id"] 、Request.Params["id"] 的强大
<form> <input type="text" name="id" value="值"> </form&g ...
- CSS3 过渡、动画、多列、用户界面
CSS3 过渡.动画.多列.用户界面 transition过渡 transition: transition-property transition-duration transition-timin ...
- PopupWindow实现点击外部不消失
View contentView = LayoutInflater.from(MainActivity.this).inflate(R.layout.alert_ip, null); final Po ...
- 粘包_Server
from socket import *# import subprocessip_port = ('127.0.0.1',8080)back_log = 5buffer_size = 1024tcp ...
- css——样式的继承
css的样式继承 在上面这段代码中,p{}为父类,b{}为子类.b{}将继承p{}. 因为<b>在<p>里面,p{}为父类,b{}为子类. 继承方式: 如果子类没有,父类有,则 ...
- logstash配置如何理解?
elasticsearch { action => "index" #The operation on ES hosts => "localhost: ...
- JS一个经典闭包问题
这里是记录一些本人在学习过程中觉得重要的知识点,记录下来以供日后查看,如有不对欢迎指正,望在前端的路上共勉! <!DOCTYPE html> <html lang="en& ...
- React 中的 refs的应用
React Refs React 支持一种非常特殊的属性 Ref ,你可以用来绑定到 render() 输出的任何组件上. 这个特殊的属性允许你引用 render() 返回的相应的支撑实例( back ...
- FastDFS 工具类实现文件上传_02
一.jar 包 jar包下载:https://pan.baidu.com/s/1nwkAHU5 密码:tlv6 或者 下载工程,安装到 maven 本地仓库 工程下载:https://pan.baid ...