android-developers.googleblog.com
Android Studio Chipmunk が Stable になったので手元環境を更新。
適当なプロジェクトを開くといつもの、
Project update recommended Android Gradle Plugin can be upgraded."
これが表示されるので進めたところ、Android Gradle plugin の更新のほかに見慣れないものが1つあった。
Move package from Android manifest to build files
Declaration of a project's namespace using the package attribute of the Android manifest is deprecated in favour of a namespace declaration in build files.
Recommended steps
These steps are not required to perform the upgrade of this project at this time, but will be required when upgrading to a later version of the Android Gradle Plugin. You can choose to do them in this upgrade to prepare for the future, with or without upgrading the Android Gradle Plugin to its new version.
差分は以下。
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - package="com.example.myapplication"> + xmlns:tools="http://schemas.android.com/tools">
build.gradle
android {
+ namespace 'com.example.myapplication'
}
ドキュメントを見ると build.gradle
で android.namespace
を定義する話は書かれている。
一方、2022/05/11 時点では package
属性が deprecated になったということが読み取れる記載は確認できなかった。
(2022/12/21 追記) Android Gradle Plugin 7.3 以上の場合はマニフェストファイルに package
属性をセットするべきではないという記述があった。
In the Gradle-based build system, starting with AGP 7.3, you shouldn't set the package value in the source manifest file directly. For more information, see Set the application ID.
(追記ここまで)
Chipmunk で新規プロジェクトも起こしてみたけれど従来通り AndroidManifest.xml
に package
属性が設定された。Recommended steps の説明で書かれている通り、今後のアップデートでは必要になるようなのでそれに合わせてここら辺も整えられると予想している。