@Composable Scaffold で This material API is experimental and is likely to change or to be removed in the future.

Jetpack Compose で Material3 を使うと、


This material API is experimental and is likely to change or to be removed in the future.

で、ビルド通らず。

AndroidStudio が提案してくる対応としては以下。

@Composable Scaffold で This material API is experimental and is likely to change or to be removed in the future.

アノテーションを付けるのもアレですね。

gradle 側から一括無視しておきましょう。


kotlinOptions {
  allWarningsAsErrors = false
  freeCompilerArgs += [
      "-Xopt-in=kotlin.RequiresOptIn",
      "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
      "-Xopt-in=kotlinx.coroutines.FlowPreview",
      "-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi",
      "-Xopt-in=kotlin.Experimental"
  ]
}

👉 Opt-in requirement marker annotation on override requires the same marker on base declaration hatena-bookmark

少し将来に向けて修正。


'-Xopt-in' → '-opt-in'

👉 '-Xopt-in' is deprecated and will be removed in a future release, please use -opt-in instead hatena-bookmark

よって、今回のビルドエラーについてのみで言えば、以下で避けるのが良さげです。


freeCompilerArgs += '-opt-in=androidx.compose.material3.ExperimentalMaterial3Api'

この記述をどこに書くか。

対象が複数になるのを考慮して


freeCompilerArgs += [
    '-opt-in=androidx.compose.material3.ExperimentalMaterial3Api',
]

としておきます。

 

build.gradle (app) allprojects/subprojects {} 内


allprojects { // subproject {
  tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {

    kotlinOptions {
      allWarningsAsErrors = false
      freeCompilerArgs += [
          '-opt-in=androidx.compose.material3.ExperimentalMaterial3Api',
      ]
    }

  }
}

 

build.gradle (module) android {} 内


android {

  kotlinOptions {
    jvmTarget = JavaVersion.VERSION_11.toString()

    allWarningsAsErrors = false
    freeCompilerArgs += [
        '-opt-in=androidx.compose.material3.ExperimentalMaterial3Api',
    ]

  }

 

build.gradle (module) の最後


dependencies {
  // ...
  debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {

  kotlinOptions {
    allWarningsAsErrors = false
    freeCompilerArgs += [
        '-opt-in=androidx.compose.material3.ExperimentalMaterial3Api',
    ]
  }

}

 

まとめ

プロジェクトの構成に合わせて、多少の拡張性を考慮しながら設定する必要があるでしょう。

👉 Opt-in requirements | Kotlin hatena-bookmark
👉 tachiyomi/build.gradle.kts at master · tachiyomiorg/tachiyomi hatena-bookmark


【macOS】横長ワイドなディスプレイで使いたいウィンドウマネージャーを探す

Split View で Mac の App を 2 つ並べて表示する
👉 Split View で Mac の App を 2 つ並べて表示する - Apple サポート (日本) hatena-bookmark

macOS 純正「Split View」は、なんとなくツラかったので、

いくつか入れてみました、無料のウィンドウマネージャー。

やりたかったのは、

「すばやくウィンドウを左右半分の大きさにして配置する」

ということです。

 

ShiftIt

インストールするといいかんじです。

Monterey でも問題なく動きます。

ShiftIt Managing window size and position in OSX
👉 fikovnik/ShiftIt: Managing windows size and position in OSX hatena-bookmark

しかし、リポジトリを見ると数年更新されていません。

This project is looking for a new maintainer. Until that transition is completed, there will likely not be further development on this project.

This project is looking for a new maintainer. Until that transition is completed, there will likely not be further development on this project.

今後、更新はされないかもしれない雰囲気です。

 

Spectacle

Move and resize windows with ease
👉 Spectacle hatena-bookmark
👉 eczarny/spectacle: Spectacle allows you to organize your windows without using a mouse. hatena-bookmark

しかし、このアプリもメンテナンス終了っぽいです。

This project is not being actively maintained.

代替として「Rectangle」なるものを推奨しています。

Spectacle users have recommended Rectangle as an open source alternative.

 

Rectangle

Rectangle: Move and resize windows on macOS with keyboard shortcuts and snap areas

当分これを使ってみることにします。

リポジトリも元気ですし、フォークやスターの数も多いです。

Rectangle: Move and resize windows on macOS with keyboard shortcuts and snap areas

👉 rxhanson/Rectangle: Move and resize windows on macOS with keyboard shortcuts and snap areas hatena-bookmark

このアプリも他のウィンドウマネージャーアプリと同様、以下のように

アクセシビリティアプリケーションにMacへのアクセスを許可する

アクセスの許可が必要になります。

👉 アクセシビリティアプリケーションにMacへのアクセスを許可する - Apple サポート (日本) hatena-bookmark

👉 多窓ブラウザは vivaldi が最強 hatena-bookmark


This version (1.2.0-alpha08) of the Compose Compiler requires Kotlin version 1.6.20 but you appear to be using Kotlin version 1.6.21 which is not known to be compatible.

こんなの出ましたけどー。


> Run with --scan to get full insights.


> Task :app:compileDebugKotlin FAILED
e: This version (1.2.0-alpha08) of the Compose Compiler requires Kotlin version 1.6.20 but you appear to be using Kotlin version 1.6.21 which is not known to be compatible.  Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).

言われるがままに、kotlin のバージョンを、1.6.20 に下げればこのエラーは消えてビルド通りますが、

Kotlin 安定版の 1.6.21 を 1.6.20 を下げる

ってのどうなのと。

 

Compose コンパイラ と Kotlin の互換性


Compose Compiler	Compatible Kotlin
1.2.0-alpha08		1.6.20
1.2.0-alpha07		1.6.10
1.2.0-alpha06		1.6.10

以下から、英語版 (言語を「English」に切り替える) にすると分かりやすいです。

👉 Compose to Kotlin Compatibility Map  |  Android Developers hatena-bookmark

Kotlin stable 1.6.21 に対応する Compose Compiler は 今現在は pre-release 版しかありません。


 

何でこんなことになるのか?


通常、安定版とアルファ版の両方が同じ日に修正された状態でリリースされると思われます。しかし、AndroidXのモノレポとその関連インフラは、実はこれを阻んでいます。リリースブランチが一つしかないので、Accompanist のような通常のプロジェクトとは異なり、別々に行うことを余儀なくされるのです。


Kotlin 1.6.20のアーティファクトがリリースされてから1週間。ComposeをアップデートするCLはリリース前にできていた。しかし、AndroidXのモノレポでは、無関係な50のライブラリを同時にアップデートすることを強制されるため、未だに不完全です。健全なプロジェクトであれば、同じ日にリリースするはずです。

Drop "androidx" from Jetpack Compose package name, for multiplatform, before 1​.​0 release.
👉 キャンペーン · Drop "androidx" from Jetpack Compose package name, for multiplatform, before 1​.​0 release. · Change.org hatena-bookmark

Compose コンパイラを開発する環境にいろいろ問題とかあるんですかね。

👉 公式 android デベロッパー の英語ページに日本語ページが遅れてる件 hatena-bookmark

 

2022-05-21 追記

1.6.21 対応の beta版がリリースされています。

compose の父が!


これも「English」ページのみ確認できます。注意です!
kotlinCompilerExtensionVersion = "1.2.0-beta02"

👉 Compose to Kotlin Compatibility Map  |  Android Developers hatena-bookmark