facebook twitter hatena line email

Android/開発環境/AndroidStudio/ビルドバージョンアップ/Android11対応

提供: 初心者エンジニアの簡易メモ
2020年7月30日 (木) 15:09時点におけるAdmin (トーク | 投稿記録)による版 (kotlinでCould not initialize class org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSetKtがる場合)

移動: 案内検索

やり方

公式:https://developer.android.com/preview/setup-sdk?hl=ja

  1. AndroidStudioのプレビュー版をDL(20200729時点で4.0.1β) https://developer.android.com/studio/preview?hl=ja
  2. Android/Tools/SDKManager (もしくはAndroidStudioのwelcome画面のConfigureのSDKManager)
  3. SDK Platformsタブで、Android R Previewを選択
  4. SDK Toolsタブで、Android SDK Build-Tools 30を選択

app/build.gradleのcompileSdkVersionとtargetSdkVersionを30へ

apply plugin: 'com.android.application'
android {
    compileSdkVersion 30
    defaultConfig {
        targetSdkVersion 30
    }
}

AndroidGradleのプラグインを4系へ

プロジェクト直下のbuild.gradle

buildscript {
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.1"
    }
}

gradle/wrapper/gradle-wrapper.propertiesのdistributionUrlを変更

distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

androidのgradleプラグインとgradleのversionの関係

こちらを参照 https://developer.android.com/studio/releases/gradle-plugin.html

kotlinでCould not initialize class org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSetKtがる場合

build.gradleのkotlin_versionを1.3.10から1.3.72にあげると直る。

buildscript {
    ext.kotlin_version = "1.3.72"
}