expo-ads-admobからreact-native-google-mobile-adsに切り替えたらbuildできなくなったときの対処法
スポンサーリンク

react-native-google-mobile-adsに切り替えたらbuildできなくて困ってませんか?

EXPO SDK 46から"expo-ads-admob"がサポートされなくなり、GitHubにあるとおり"react-native-google-mobile-ads"に切り替えてからBuildしてみると下記のようなエラーがでてお困りではありませんか?

...
Error: Compatible versions of some pods could not be resolved.
You are seeing this error because either:
  - Some of the pods used in your project depend on different versions of the same pod. See logs for more information.
  - If you are caching Podfile.lock using "cache" field in eas.json, then versions there might not match required values in Podspecs of some installed libraries. To fix this, you can re-run build command with "--clear-cache" option, or select "Clear cache and retry build" on the build page.
この記事でわかること
  • Error: Compatible versions of some pods could not be resolved.のエラーを理解できる
  • Error: Compatible versions of some pods could not be resolved.のエラーに対処できる
スポンサーリンク

エラーを理解する

私が遭遇したエラーの全体を見てみます。

この中で特に注意して見るべきなのは"[!] CocoaPods could not find compatible versions for pod "Google-Mobile-Ads-SDK":"から下の部分になります。

ここには"expo-ads-admob"に含まれる"Google-Mobile-Ads-SDK (= 8.13.0)"と

"react-native-google-mobile-ads"に含まれる"Google-Mobile-Ads-SDK (= 10.9.0")

バージョン違うけどどっちSDKを使えばいいの?って怒られています。

なのでもう使わない"expo-ads-admob"をライブラリから消せばOKなんです!

Using Expo modules

[Expo] Enabling modular headers for pod ExpoModulesCore

[Expo] Enabling modular headers for pod EXImageLoader

Auto-generating `.xcode.env.local` with $NODE_BINARY=/Users/expo/.nvm/versions/node/v16.18.1/bin/node

Adding a custom script phase for Pod RNGoogleMobileAds: [RNGoogleMobileAds] Configuration

Auto-linking React Native modules for target `de`: RNCAsyncStorage, RNGoogleMobileAds, RNSVG, RNScreens, RNVectorIcons, react-native-netinfo, react-native-safe-area-context, react-native-slider, and react-native-view-shot

Framework build type is static framework

[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json

Analyzing dependencies

Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`

[Codegen] Found FBReactNativeSpec

Fetching podspec for `RCT-Folly` from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`

Fetching podspec for `boost` from `../node_modules/react-native/third-party-podspecs/boost.podspec`

Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`

Fetching podspec for `hermes-engine` from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`

Adding spec repo `trunk` with CDN `https://cdn.cocoapods.org/`

CocoaPods 1.12.1 is available.

To update use: `gem install cocoapods`

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.12.1

[!] CocoaPods could not find compatible versions for pod "Google-Mobile-Ads-SDK":

  In Podfile:

    EXAdsAdMob (from `../node_modules/expo-ads-admob/ios`) was resolved to 13.0.0, which depends on

      Google-Mobile-Ads-SDK (= 8.13.0)

    RNGoogleMobileAds (from `../node_modules/react-native-google-mobile-ads`) was resolved to 12.0.0, which depends on

      Google-Mobile-Ads-SDK (= 10.9.0)

Error: Compatible versions of some pods could not be resolved.
You are seeing this error because either:
  - Some of the pods used in your project depend on different versions of the same pod. See logs for more information.
  - If you are caching Podfile.lock using "cache" field in eas.json, then versions there might not match required values in Podspecs of some installed libraries. To fix this, you can re-run build command with "--clear-cache" option, or select "Clear cache and retry build" on the build page.
スポンサーリンク

エラーの対処法

手順はいたってシンプルです。

  1. package.jsonから"expo-ads-admob"を削除する。
  2. node-modulesフォルダを削除する
  3. 再度ライブラリをインストールする

これだけ!

最後に...

いかがだったでしょうか?エラーをしっかり読めば簡単な話なんですがしっかりと対処するのは難しいですよね!

私はエラー対処中にiOS buildが15回/月を超えてしまって、とってもモヤモヤしてました。

この記事が皆様の時間短縮になることを祈っております。

参考サイト

https://github.com/expo/expo-ads-admob

https://github.com/expo/expo/issues/15248

Twitterでフォローしよう

おすすめの記事