LoginSignup
4
3

More than 3 years have passed since last update.

ReactNativeでAndroidが起動しない

Last updated at Posted at 2019-06-28

概要

※自分の場合はAndroidXのリリースの影響でした

2019年6月末くらいにReactNativeプロジェクトでAndroidが起動しなくなった。

Android resource linking failed
...
Daemon:  AAPT2 aapt2-3.2.0-4818971-osx Daemon #0

省略していますが、私の環境でのエラー内容はこんな感じです。
環境によって違うかと。
(別の環境では使用しているパッケージでエラーが出ていた)

AAPT2で調べてたけど、全く解決せず。

前提

react-native 0.54.4(verは関係なさそう)

理由

AndroidXのリリース
https://developers.google.com/android/guides/releases/#june_17_2019

com.google.android.gms:play-services-gcm
com.google.firebase:firebase-messaging
がAndroidXをサポートしたから?

implementation "com.google.android.gms:play-services-gcm:${safeExtGet('googlePlayServicesVersion', '+')}"
のように最新バージョンを取ってくるとダメぽい

パッケージも同じ

react-native-push-notificationのエラーが出て悩んだ結果

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

こちらの記事にたどり着いた。

react-native-device-info
react-native-push-notification
など、同じ問題が発生している。

解決

※私の場合

1.android/build.gradle

googlePlayServicesVersion = "+"
firebaseVersion = "+"

自分のプロジェクトではこうなっていたので

googlePlayServicesVersion = "16.+"
firebaseVersion = "17.6.0"

バージョンを固定する。

2.android/gradle.properties

googlePlayServicesVersion=16.+
firebaseVersion=17.6.0

追記しておけば、パッケージはこっちのバージョンを見に行くので個別に変更しなくていい

3.react-native run-android

最後に

Twitterを見てたら解決しました。

参考

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

AndroidX関連の変更によるReact Native Androidのビルドエラーを回避した

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