LoginSignup
1
1

More than 3 years have passed since last update.

ReactNative実行時のエラー解決メモ

Posted at

react nativeを0.57.3から0.59.8に上げて実行したらエラーがたくさん出たので解決方法をメモしておきます。

android

Could not get unknown property 'mergeResourcesProvider' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl.

https://github.com/wix/react-native-navigation/issues/4757#issuecomment-468133753
上記コメント通りに対応すれば解決しました。
metro.config.jsファイルを作成するとありますが、0.59の正式リリースで必要なくなったみたいなので作らなくて大丈夫です。
また、バージョンはいきなり全て最新にすると依存関係でハマったりするので、メジャーバージョンを少しづつあげていく方がいいと思います。

Execution failed for task ':app:processDebugResources'.
 Android resource linking failed

  /Users/<USER_NAME>/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/6f6de8a5350930056a96225b06ab7a16/res/values-v28/values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
  /Users/<USER_NAME>/<PROJECT_NAME>/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml:11: AAPT: error: resource android:attr/dialogCornerRadius not found.
  /Users/<USER_NAME>/.gradle/caches/transforms-1/files-1.1/drawee-1.10.0.aar/603dac14beab9d235ac515ad5b5f1fe7/res/values/values.xml:3:5-58:857: AAPT: error: resource android:attr/fontVariationSettings not found.
  /Users/<USER_NAME>/.gradle/caches/transforms-1/files-1.1/drawee-1.10.0.aar/603dac14beab9d235ac515ad5b5f1fe7/res/values/values.xml:3:5-58:857: AAPT: error: resource android:attr/ttcIndex not found.

  error: failed linking references. 

ググってみるとcompileSdkVersionを上げると解決するらしい。27だったので28にして実行したら解決した。
ちなみにtargetSdkVersionも上げると別のエラーがいろいろと…
いつか上げなきゃいけない日が来ますが今はとりあえず動けばいいのでそのままで。

androidはとりあえず上記のエラーだけで起動しました。動作確認も特に問題なく一安心。

iOS

iOSは色々と厄介で何度もキャッシュ消したりして時間がかかりました。

** BUILD FAILED **

The following commands produced analyzer issues:
        Analyze /Users/<USER_NAME>/<PROJECT_NAME>/node_modules/react-native/ReactCommon/jsi/jsi.cpp normal x86_64
        Analyze /Users/<USER_NAME>/<PROJECT_NAME>/node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp normal x86_64
        Analyze Base/RCTModuleMethod.mm normal x86_64
(3 commands with analyzer issues)

The following build commands failed:
        CompileC /Users/<USER_NAME>/<PROJECT_NAME>/ios/build/CRIA/Build/Intermediates.noindex/RNFirebase.build/Debug-iphonesimulator/RNFirebase.build/Objects-normal/x86_64/RNFirebaseMessaging.o RNFirebase/messaging/RNFirebaseMessaging.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

iOSだとエラーで止まると最後にこのようなログが出てきますが、ここには具体的なエラーの内容が書かれてないのでそのままググってもあまり意味ないです。
大量のログを少しずつ遡ってerror catchあるいは1 error generated.と出力されている直前の行にエラーの中身が出力されています。

pch was compiled with module cache path ~ , but the path is currently ~

ios/Build/PROJECT_NAME/ModuleCache.noindexフォルダを削除すると解決。

'folly/Portability.h' file not found

https://github.com/facebook/react-native/issues/24192#issuecomment-479497777
ここのpod 'Folly'以下をPodFileに追加してpod installする。
それでもエラーが出る場合はios/PodsフォルダとPodfile.lockを削除して再度pod installする。

info ** BUILD SUCCEEDED **

info Installing build/CRIA/Build/Products/Debug-iphonesimulator/<APP_NAME>.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
error Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/CRIA/Build/Products/Debug-iphonesimulator/<APP_NAME>.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
. Run CLI with --verbose flag for more details.
error Command failed with exit code 1.

あー…ここでこのエラーですか…
ネットにある色んな解決方法を大方試してみるも解決せず…

埒が明かないのでXcodeからアプリを実行してみる。(実行するときはxcworkspaceから実行しないとエラーになるので注意)

……何事もなくアプリが起動:joy:
なんでよ…と思いつつ再度コマンドで実行してみるもやっぱりダメ。

この後更に色々試しましたが、結局解決できなかったのでめんどくさいけどXcodeから実行することにしましたorz

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