别裁伪体亲风雅,转益多师是汝师。这篇文章主要讲述AndroidStudio kotlin配置相关的知识,希望能为你提供帮助。
安装插件File ->
Settings ->
Plugins ->
Browse repositories ->
搜索 kotlin
gradle添加依赖Module的build.gradle
apply plugin: ‘com.android.application‘ apply plugin: ‘kotlin-android‘ apply plugin: ‘kotlin-android-extensions‘android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { applicationId "com.lxs.kotlinconfig" minSdkVersion 15 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘ } } }dependencies { compile fileTree(dir: ‘libs‘, include: [‘*.jar‘]) androidTestCompile(‘com.android.support.test.espresso:espresso-core:2.2.2‘, { exclude group: ‘com.android.support‘, module: ‘support-annotations‘ }) compile ‘com.android.support:appcompat-v7:25.3.1‘ compile ‘com.android.support.constraint:constraint-layout:1.0.2‘ testCompile ‘junit:junit:4.12‘
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" }repositories { maven {url ‘http://maven.aliyun.com/nexus/content/groups/public/‘} }
Project的
build.gradle
buildscript { ext.kotlin_version = ‘1.1.2-4‘ repositories { maven {url ‘http://maven.aliyun.com/nexus/content/groups/public/‘} } dependencies { classpath ‘com.android.tools.build:gradle:2.3.2‘ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"// NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }allprojects { repositories { maven {url ‘http://maven.aliyun.com/nexus/content/groups/public/‘} } }task clean(type: Delete) { delete rootProject.buildDir }
kotlin.incremental=true增量编译的机制,可以加快编译速度 项目根目录的gradle.properties里配置
把java代码转换成kotlin代码
Code -> Convert Java File to Kotlin File
快捷键 ctrl+alt+shift+k
或者ctrl+shift+A输入Convert Java File to Kotlin File
【AndroidStudio kotlin配置】
推荐阅读
- 本文教大家如何安装win7系统
- qt on android之GPS信号的获取
- 写给Android App开发人员看的Android底层知识
- android makefile文件批量拷贝文件的方法
- Android上方便地开发的C程序
- Android DatePickerDialog样式不一致的问题
- Android 开发 ContentProvider 获取歌曲列表和联系人的样例
- 扫码订餐系统app开发
- 关于点击Invalidate Caches/Restart禁止插件后,重新加载--Android Studio