编程基础之Kotlin语言

Kotlin是Google认定的Android官方开发语言,中文资源:语言参考mobi格式
著名的ss改用Kotlin了
目的:我不想学Java,又想开发Android程序,入门时也不想用集成开发环境

扩展名:kt(Kotlin文件),kts(Kotlin脚本)

一、不限制编辑器,安装Kotlin,参考Working with the Command Line Compiler

1、下载Kotlin,比如kotlin-compiler-1.2.21.zip,解压缩,在bin目录下新建hello.kt,用power shell打开这个目录的命令行状态

2、.\kotlinc hello.kt -include-runtime -d hello.jar #编译,参数:-d: 用来设置编译输出的名称,可以是 class 或 .jar 文件,也可以是目录。-include-runtime : 让 .jar 文件包含 Kotlin 运行库,从而可以直接运行。,有警告,啥意思?

3、java -jar hello.jar #运行OK
hello.kt
fun main(args: Array) {

println(“Hello, World!”)

}
类似python,可以运行 REPL(交互式解释器)
./kotlinc-jvm #有几行与编译时相同的警告,Windows 10 power shell 下,当前目录的可执行文件也要加路径,类似Linux

>>>2+2

>>>println(“hello,world”)
Kotlin 教程
官网:https://kotlinlang.org/

开发Android程序

使用Kotlin开发Android–Hello World环境搭建
Android Studio设置shadowsocks代理
Getting Started with Android Studio

下载Android Studio并缺省安装 #比如“android-studio-ide-171.4443003-windows.exe”

首次启动IDE时,报错Unable to access Android SDK add on list,如果本地开启了ss,系统代理模式为“全局代理”,并选中了来自局域网的连接,就可以在报错页面设置代理为sock类型,127.0.0.1,端口1080来解决翻墙问题。大约需要下载1G的文件。