1

The error:

Error:Execution failed for task ':synclib:compileKotlin'.
> com.intellij.openapi.fileTypes.LanguageFileType.<init>(Lcom/intellij/lang/Language;)V

The build.gradle file of the synclib module:

apply plugin: 'java'
apply plugin: 'kotlin'


compileJava {
    sourceCompatibility = 1.7
    targetCompatibility = 1.7
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
//    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.firebase:firebase-client-jvm:2.2.3'
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    compile project(':jamodel')

}
buildscript {
    ext.kotlin_version = '1.0.0'
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

repositories {
    mavenCentral()
}

How to fix or diagnose this?

8
  • 4
    Did you try using Kotlin 1.0.4 instead of 1.0.0 ? Also, what's your gradle plugin version? Commented Oct 23, 2016 at 19:51
  • With ext.kotlin_version = '1.0.4' the error that happens is: Error:Execution failed for task ':cloudtimemodel:compileKotlin'. > Could not initialize class com.intellij.ide.highlighter.JavaFileType Commented Oct 24, 2016 at 14:33
  • @Logain: which Gradle plugin do you mean? The one for Kotlin? If so, it is classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" Commented Oct 24, 2016 at 14:34
  • 1
    I was asking about the build tools too, i.e.: classpath 'com.android.tools.build:gradle:2.2.2' Commented Oct 24, 2016 at 19:08
  • 1
    Possible duplicate of Android Studio build failed with Kotlin Commented Oct 25, 2016 at 17:08

3 Answers 3

2

This is a working configuration. You can adapt it to your multi-project setup:

/build.gradle

buildscript {
    ext.kotlin_version = '1.0.4'
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        jcenter()
    }

    ext {
        androidBuildToolsVersion = "23.0.3"
        androidMinSdkVersion = 16
        androidTargetSdkVersion = 23
        androidCompileSdkVersion = 23
        androidApplicationId = "com.some.example"
        androidVersionCode = 1
        androidVersionName = "1.0"
        supportVersion = "24.0.0"
    }
}

/app/build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion parent.ext.androidCompileSdkVersion
    buildToolsVersion parent.ext.androidBuildToolsVersion

    defaultConfig {
        minSdkVersion parent.ext.androidMinSdkVersion
        targetSdkVersion parent.ext.androidTargetSdkVersion
        versionCode parent.ext.androidVersionCode
        versionName parent.ext.androidVersionName
    }

    buildTypes {
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }

    dexOptions {
        preDexLibraries = false
        jumboMode = false
        javaMaxHeapSize "4g"
    }
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! I will check one-by-one, where we might differ.
1

ensure all your apps and libs build.gradle's ext.kotlin_version equal to your installed Kotlin version

buildscript {
    ext.kotlin_version = PROP_KOTLIN_VERSION // 1.1.2-3 // this should equal to your installed Kotlin version
    //...
}

Comments

0

Follow these instructions or check: https://kotlinlang.org/docs/tutorials/kotlin-android.html

  1. Choose Help | Find Action on the main menu or press CTRL+Shift+A.
  2. Search for this item:enter image description here
  3. You would be prompted for kotlin version.

*emphasized text* Choose the latest available from the list of installed versions.

  1. Now build.gradle file for the application should be updated.

  2. The last thing to do is to sync the project. You can press 'Sync Now' in a prompt or invoke an action Sync Project with Gradle Files.

Hope it will help

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.