Android Studio에서 java 와 kotlin을 혼용해서 사용할 수 있다길래 적용하고 여기에 적어둔다.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.0"
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61' //추가
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61' 를 dependencies에 추가한다.
plugins {
id 'com.android.application'
}
apply plugin: 'kotlin-android' //추가
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.hiker"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.0.0' //추가
}
//추가
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
pluugin 을 apply하고 implementation를 dependencies에 넣고
sourceSets{} 추가
추가하면서 계속 Sync 시키고 실행 테스트해보기