21
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

React NativeでAndroidXに関する変更でAndroidのビルドができなくなったのに対応した

Posted at

はじめに

2019/6/17までAndroidのビルドができていましたが、2019/6/18にAndroidのみエラーが出るようなりました。
(react-native: "0.59.8", react-native: "0.59.9" の環境で発生を確認しています。)

※ プルリクがマージされれば問題なくなると思いますが、ここ数日でリリースなどがあって困っている方もいるかもと思い記事にまとめておきます。

エラー内容

> Task :app:processDebugManifest FAILED
/Users/XXX/android/app/src/debug/AndroidManifest.xml:22:18-91 Error:
        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:7:5-117 to override.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> 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:7:5-117 to override.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
155 actionable tasks: 3 executed, 152 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug. 

原因

react-native-push-notification

下記のAndroidXに関するリリースが原因の様子でした。
https://developers.google.com/android/guides/releases

上記以外にもreact-native-device-infoも該当している様子でしたが、こちらは既にAndroidXに対応して修正されていました。

▼ react-native-device-infoの該当変更箇所
https://github.com/react-native-community/react-native-device-info/commit/ec930b3f61da83e46cd70ecd108e0fe7a873fcb0

解決方法

プルリクされているものがまだマージされていない為、react-native-push-notification をreact-native-device-infoの該当変更箇所を参考にforkして対応しました。

▼ Issue
https://github.com/zo0r/react-native-push-notification/issues/1091#issuecomment-502992413

▼プルリクはすでに投げてくれていました。感謝…!
https://github.com/zo0r/react-native-push-notification/pull/1092

21
11
2

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
21
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?