質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Q&A

解決済

1回答

4250閲覧

エラーAndroid studio で Manifest merger failed が発生してしまう

Aki_1988

総合スコア44

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

0グッド

0クリップ

投稿2018/12/02 11:13

編集2018/12/02 14:47

前提・実現したいこと

Android studio で sync した際に発生するエラーを解消したい。

エラー発生の経緯

Material component の BottomAppBar を実装するため、build.gradle(app)implementation 'com.google.android.material:material:1.0.0'を追加。初回の sync は問題なくできたが、いくつかの作業を行い再び sync したところ、エラー発生。具体的には、BottmAppBar がうまく表示されず、BottomAppBar 関連で追加したコードを消したあとに sync して発生。
implementation 'com.google.android.material:material:1.0.0'を削除すると、エラーは解消されます。

追加箇所

dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.google.android.material:material:1.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' }

上記コードは、以下を参考に追加しました。
https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md

https://www.youtube.com/watch?v=g27dEyx-zYU&t=186s

発生している問題・エラーメッセージ

エラー

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-19:19 to override.

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.xxx.xxx"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application> </manifest>

試したこと

以下サイトを参考に、
Refactor to AndroidXを実行。
https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md

tools:replace="android:appComponentFactory"を application に追加すると以下エラーが発生。

Cause: org.xml.sax.SAXParseException; systemId: file:/Users/xxx/AndroidStudioProjects/xxx/app/src/main/AndroidManifest.xml; lineNumber: 12; columnNumber: 57; 要素タイプ"application"に関連付けられている属性"tools:replace"の接頭辞"tools"がバインドされていません。 要素タイプ"application"に関連付けられている属性"tools:replace"の接頭辞"tools"がバインドされていません。

補足情報(FW/ツールのバージョンなど)

SDK
イメージ説明

とても初歩的な質問かと思いますが、どうぞよろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

自己解決しました。

manifest に追加
xmlns:tools="http://schemas.android.com/tools"

application に追加
tools:node="replace"

詳しくは理解できてないので、要勉強。

投稿2018/12/02 14:59

Aki_1988

総合スコア44

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問