@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


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

'-Xopt-in' is deprecated and will be removed in a future release, please use -opt-in instead
👉 Issues with Gradle Kotlin DSL and `-Xopt-in` deprecation : KT-51708 hatena-bookmark


tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
   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",
     ]
   }
 }


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


tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
   kotlinOptions {
     allWarningsAsErrors = false
     freeCompilerArgs += [
         "-opt-in=kotlin.RequiresOptIn",
         "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
         "-opt-in=kotlinx.coroutines.FlowPreview",
         "-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
         "-opt-in=kotlin.Experimental",
     ]
   }
 }

単純に gradle ファイル内、文字列の置換で完。

コード内アノテーションで利用の人はそのままでいいんかな。

👉 Opt-in requirement marker annotation on override requires the same marker on base declaration  hatena-bookmark
👉 AGP Upgrade Assistant で 7.2 移行時にCause: manifestData.`package` must not be null hatena-bookmark
👉 @Composable Scaffold で This material API is experimental and is likely to change or to be removed in the future. hatena-bookmark