Android StudioのOutdated Kotlin Runtime
Android StudioでGradle pluginをアップデートしたら、Outdated Runtime Kotlin
と警告されるようになりました。
Your version of Kotlin runtime in 'org.jetbrains.kotlin:kotlin-stdlib:1.1.51@jar' library is 1.1.51, while plugin version is 1.2.31-release-Studio3.0-1. Runtime library should be updated to avoid compatibility problems. Update Runtime Ignore
ところが、RuntimeをUpdateしろと言うならそうしましょうと思ってUpdate Runtime
を選択しても、自動でUpdateはできないので自分でbuild.gradle
を Updateしろと言われます。
Update Kotlin Runtime Library Automatic library version update for Maven and Gradle projects is currently unsupported. Please update your build.gradle manually.
じゃあ、build.gradle
を書き換えようとモジュールディレクトリ(app)のbuild.gradle
を開いたものの、1.1.51
の記述が見つかりません。
build.gradle(Module: app)
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 26 defaultConfig { applicationId "com.example.b0npu.hellokotlin" minSdkVersion 23 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' }
build.gradle(Project: Project Name)
Outdated Runtime Kotlin
で検索してみると、いつものようにStack Overflowに辿り着き、ここで初めて、build.gradle
にはProjectとModuleの2種類が存在する事を知りました。
・プロジェクトディレクトリ(Application Name)→モジュールディレクトリ(app)→build.gradle(Module: Module Name)
・プロジェクトディレクトリ(Application Name)→build.gradle(Project: Project Name)
プロジェクトディレクトリ直下のbuild.gradle(Project: Project Name)
を開くと、あっさりとext.kotlin_version = '1.1.51'
の記述を見つけてUpdateできました。
build.gradle(Project: HelloKotlin)
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.1.51' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.1.0' 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 { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir }
開発環境
- OSX 10.11.6 El Capitan
- IDE: Android Studio 3.0.1
- Android Virtual Device: Android 6.0(Google APIs) API level 23 - Kotlin 1.2.31
- ビルドシステム: Gradle 4.4