1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AGP 8.8 での Manifest merger failed エラーとその解決策

Posted at

前回の記事では、Android Gradle Plugin (AGP) を 7 から 8 へアップデートした際に発生した BuildConfigR クラスの生成に関する変更点とその解決策を記載しました。
今回は、AGP 8.8 へアップデートした際に遭遇した Manifest merger failed : Attribute property#android.adservices.AD_SERVICES_CONFIG@resource... エラーについてに対応した内容を記載します

1. エラーの再現と詳細なエラーメッセージの解析

AGP を 8.8 へアップデート後、プロジェクトのビルド時に以下のようなエラーが発生しました。

Manifest merger failed : Attribute property#android.adservices.AD_SERVICES_CONFIG@resource value=(@xml/gma_ad_services_config) from com.google.android.gms:play-services-ads-lite:23.3.0] AndroidManifest.xml:92:13-59
	is also present at [com.google.android.gms:play-services-measurement-api:22.0.2] AndroidManifest.xml:32:13-58 value=(@xml/ga_ad_services_config).
	Suggestion: add 'tools:replace="android:resource"' to <property> element at AndroidManifest.xml to override.

このエラーは、異なるライブラリで定義されている android.adservices.AD_SERVICES_CONFIG 属性が競合していることを示しています。
具体的には、com.google.android.gms:play-services-ads-litecom.google.android.gms:play-services-measurement-api がそれぞれ異なる AD_SERVICES_CONFIG リソースを定義しているため、マニフェストのマージに失敗していました。

2. 実施した解決策:tools:replace を使用してオーバーライド

エラーメッセージの Suggestion に記載されている通り、tools:replace="android:resource" を AndroidManifest.xml に追加することで、この問題を解決できます。

具体的には、アプリケーションの AndroidManifest.xml ファイル内の タグ内に、以下のように タグを追加します。

app/src/main/AndroidManifest.xml
<application>

  <property
      android:name="android.adservices.AD_SERVICES_CONFIG"
      android:resource="@xml/gma_ad_services_config"
      tools:replace="android:resource" />

</application>

この設定により、com.google.android.gms:play-services-ads-lite で定義されている gma_ad_services_config リソースを優先的に使用するように指定することができました。

1
3
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
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?