2017-08-02 102 views
1

我addded罐子需要,Android的 - 不能添加在java8創建罐子科特林

sourceCompatibility JavaVersion.VERSION_1_8 
targetCompatibility JavaVersion.VERSION_1_8 

需要插口,支持java8。

根據最新的kotlin插件給出,錯誤:Kotlin Gradle插件不支持棄用的Jack工具鏈。 禁用傑克或恢復到Kotlin Gradle插件1.1.1版。

當前不能用java7重新創建jar。並且需要使用已棄用Jack工具鏈的最新版本的kotlin。

我檢查app.gradle中的所有可能的方法。

根據this,無法通過studio 3.0預覽版解決此問題。

enter image description here

項目級別gradle這個文件,

// Top-level build file where you can add configuration options common to all sub-projects/modules. 
buildscript { 
    ext.kotlin_version = '1.1.3' 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.3.3' 
     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 { 
     jcenter() 
    } 
} 

應用水平gradle這個文件,

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

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.3" 
    defaultConfig { 
     applicationId "com.example.root.trial" 
     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' 
     } 
    } 
    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_8 
     targetCompatibility JavaVersion.VERSION_1_8 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    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 files('libs/bel-1.0.jar') 
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" 
} 
repositories { 
    mavenCentral() 
} 
+0

你試過用android gradle插件3.0.0-alpha9嗎? – DeKaNszn

+0

[Kotlin and Jack unsupported(Android Studio 2.3.2)]可能的重複](https://stackoverflow.com/questions/44105504/kotlin-and-jack-unsupported-android-studio-2-3-2) –

+0

@提供解決方案使用低於1.1.1 kotlin版本的Stas,但在我的情況下需要使用最新版本。 – paril

回答

1

您還沒有更新插件的gradle中的build.gradle(:項目)。

替換你的項目的gradle級文件,如下:

buildscript { 
    ext.kotlin_version = '1.1.3-2' 
    repositories { 
     maven { url 'https://maven.google.com' } 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:3.0.0-alpha9' 
     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 'https://maven.google.com' } 
     jcenter() 
    } 
} 

我希望它能幫助。

+0

是的,它的工作..我真的很感激你的幫助。 – paril