0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

掌田 津耶乃著『Android Jetpack プログラミング』の歩き方(Section4-2) Kotlin-Android-Extensionsの設定

Posted at

#1. はじめに
 掌田 津耶乃著『Android Jetpack プログラミング』(以下、本書と言う)で勉強しています。この本は、著者が記述しているように入門書ではないようです。それゆえ、本書をしっかりと読み込んでいないと、記載されているソースコード通りに写経しても、エラーで弾かれることがあります。本レポートでは、「『Android Jetpack プログラミング』の歩き方」と題して、掌田 津耶乃著『Android Jetpack プログラミング』の歩き方(Section3-1)に引き続き、ソースコードどうりに写経してアプリが正常に動くようにするための注意点をレポートします。記述や考え方などに誤りがあれば、ぜひご教示いただきたいと思います。

2. 動作環境

 2021年5月6日ごろ、当方のAndroidStuidoが4.2にアップグレードしました。以下の動作条件で本記事の内容を確認しました。

Android Studio 4.2
Build #AI-202.7660.26.42.7322048, built on April 29, 2021
Runtime version: 11.0.8+10-b944.6842174 amd64
VM: OpenJDK 64-Bit Server VM by N/A
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 8
Registry: documentation.show.toolbar=true, external.system.auto.import.disabled=true
Non-Bundled Plugins: org.jetbrains.kotlin

 なお、AndroidStuidoが4.2にアップグレードに伴って、Kotlinコンパイラも1.5にアップデートしたようで少し不具合が出ているようです。
 そのため、build.gradleのprojectの方(buildscriptのext.kotlin_version)を以下のとおり変更してました(ググった結果、このように変更すればいいとあったのでこのように変更しました)。本不具合が早く解消されることを願います。

build.gradle#project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.5.0"    // <-- 変更
    repositories {
        google()
        mavenCentral()
    }
    // 以下省略

3. Section4-2以降を写経する上での注意点

 先にレポートしたSection3-1同様、Section4-2以降でも、Kotlin-Android-Extensionsを使用しているため、build.gradleのModule:appに対して、以下のとおりプラグインの追加の設定が必要です。Kotlin-Android-Extensionsについては本書p61を参照して下さい。

build.gradle#app
plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-android-extensions'    // 追記
}

// ・・・

以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?