I have installed the kotlin plugin into my android studio project.The code complies with out an issue. It also executes when I call it from a java class. It is giving me the warning "Some Kotlin libraries attached to this project have unsupported format.Please update the libraries or the plugin". The println() function is also not being recognized in the IDE.
test.kt
fun foo(){
println("ad")
}
public class iTar{
public fun printAll( vararg a: String ){
for(item in a)println(item)
}
}
Build.Gradle
buildscript
{
ext.kotlin_version = '0.8.679'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
packagingOptions {
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
defaultConfig {
applicationId "xxxxx"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.codehaus.jackson:jackson-mapper-lgpl:1.9.13'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'org.mapsforge:svg-android:0.4.3'
compile 'com.android.support:support-v4:20.+'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
repositories {
mavenCentral()
}
Update to a new release IntelliJ IDEA and Android Studio suggest updating to a new release once it is out. When you accept the suggestion, it automatically updates the Kotlin plugin to the new version. You can check the Kotlin plugin version in Tools | Kotlin | Configure Kotlin Plugin Updates.
Step 1: Setup the Kotlin Plugin in Android Studio. In order to ensure Android Studio support Kotlin, the first thing is to install the Kotlin Plugin for your Android Studio. Step 2: Add Kotlin classpath to project Build. Step 3: Add Kotlin library and apply Kotlin Plugins in your module Build.
You can check the Kotlin version in Tools | Kotlin | Configure Kotlin Plugin Updates. If you have projects created with earlier Kotlin versions, change the Kotlin version in your projects and update kotlinx libraries if necessary.
The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio. The plugin supports Kotlin 1.7 and lower.
Your problem comes from using Kotlin 0.8.679 in your Gradle build, which is too new for the Kotlin plugin you are using in the IDE. Two possible solutions:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With