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

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

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

AdMobは、事前に指定した条件に従ってアプリに広告を表示するGoogleのサービス。開発者の向けのサービスで、広告を掲載することにより、収益を得ることが可能です。その他、見た目や雰囲気などアプリに合う広告に変更したり、広告表示の場所を指定することもできます。

Flutter

Flutterは、iOSとAndroidのアプリを同じコードで開発するためのフレームワークです。オープンソースで開発言語はDart。双方のプラットフォームにおける高度な実行パフォーマンスと開発効率を提供することを目的としています。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

iOS

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

Dart

Dartは、Googleによって開発されたJavaScriptの代替となることを目的に作られた、ウェブ向けのプログラミング言語である。

Q&A

解決済

1回答

3363閲覧

【Flutter/Dart】iOSアプリにgoogle_mobile_adsを使うとCocoaPods関連のエラーで起動しない

tantan1

総合スコア31

AdMob

AdMobは、事前に指定した条件に従ってアプリに広告を表示するGoogleのサービス。開発者の向けのサービスで、広告を掲載することにより、収益を得ることが可能です。その他、見た目や雰囲気などアプリに合う広告に変更したり、広告表示の場所を指定することもできます。

Flutter

Flutterは、iOSとAndroidのアプリを同じコードで開発するためのフレームワークです。オープンソースで開発言語はDart。双方のプラットフォームにおける高度な実行パフォーマンスと開発効率を提供することを目的としています。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

iOS

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

Dart

Dartは、Googleによって開発されたJavaScriptの代替となることを目的に作られた、ウェブ向けのプログラミング言語である。

0グッド

0クリップ

投稿2021/06/19 10:23

編集2021/06/20 11:49

FlutterでiOSアプリにgoogle_mobile_adsを使うと、以下のようにCocoaPods関連のエラーで起動しません。
解決方法を教えてもらえないでしょうか。

●エラー

Terminal

1Launching lib/main.dart on iPhone 11 in debug mode... 2Running Xcode build... 3Xcode build done. 11.3s 4Failed to build iOS app 5Error output from Xcode build: 67 objc[42521]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x20c6bec10) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x122d802b8). One of the two will be used. Which one is undefined. 8 objc[42521]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x20c6bec60) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x122d80308). One of the two will be used. Which one is undefined. 9 ** BUILD FAILED ** 10 11 12Xcode's output: 1314 Error: Cannot run with sound null safety, because the following dependencies 15 don't support null safety: 16 17 - package:google_mobile_ads 18 19 For solutions, see https://dart.dev/go/unsound-null-safety 20 21 Command PhaseScriptExecution failed with a nonzero exit code 22 note: Using new build system 23 note: Building targets in parallel 24 note: Planning build 25 note: Analyzing workspace 26 note: Constructing build description 27 note: Build preparation complete 28 /Users/flutter/adtest/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99. (in target 'Flutter' from project 'Pods') 29 30Could not build the application for the simulator. 31Error launching application on iPhone 11. 32

●実行環境

Flutter 2.2.2 • channel stable • https://github.com/flutter/flutter.git Framework • revision d79295af24 (8 days ago) • 2021-06-11 08:56:01 -0700 Engine • revision 91c9fc8fe0 Tools • Dart 2.13.3 OS:Mac 11.4 (M1 MacBook Air) IDE:Android Studio 4.2.1

●main.dart

dart

1import 'package:flutter/material.dart'; 2import 'package:google_mobile_ads/google_mobile_ads.dart'; 3import 'dart:io'; 4void main() { 5 //以下の二行を追加 6 WidgetsFlutterBinding.ensureInitialized(); 7 MobileAds.instance.initialize(); 8 //追加ここまで 9 runApp(MyApp()); 10} 11 12class MyApp extends StatelessWidget { 13 // This widget is the root of your application. 14 15 Widget build(BuildContext context) { 16 return MaterialApp( 17 title: 'Flutter Demo', 18 theme: ThemeData( 19 primarySwatch: Colors.blue, 20 ), 21 home: MyHomePage(title: 'Flutter Demo Home Page'), 22 ); 23 } 24} 25 26class MyHomePage extends StatefulWidget { 27 MyHomePage({Key? key, required this.title}) : super(key: key); 28 29 final String title; 30 31 32 _MyHomePageState createState() => _MyHomePageState(); 33} 34 35class _MyHomePageState extends State<MyHomePage> { 36 // This widget is the root of your application. 37 final BannerAd myBanner = BannerAd( 38 adUnitId: getTestAdBannerUnitId(), 39 size: AdSize.banner, 40 request: AdRequest(), 41 listener: AdListener(), 42 ); 43 44 Widget build(BuildContext context) { 45 myBanner.load(); 46 47 final AdWidget adWidget = AdWidget(ad: myBanner); 48 49 final Container adContainer = Container( 50 alignment: Alignment.center, 51 child: adWidget, 52 width: myBanner.size.width.toDouble(), 53 height: myBanner.size.height.toDouble(), 54 ); 55 return Scaffold( 56 appBar: AppBar( 57 title: Text(widget.title), 58 ), 59 body: Center( 60 61 child: Column( 62 63 mainAxisAlignment: MainAxisAlignment.center, 64 children: <Widget>[ 65 adContainer, 66 ], 67 ), 68 ), 69// This trailing comma makes auto-formatting nicer for build methods. 70 ); 71 } 72} 73 74//プラットホームごとのテスト広告IDを取得するメソッドをどこかに配置してください。 75String getTestAdBannerUnitId(){ 76 String testBannerUnitId = ""; 77 if(Platform.isAndroid) { 78 // Android のとき 79 testBannerUnitId = "ca-app-pub-3940256099942544/6300978111"; 80 } else if(Platform.isIOS) { 81 // iOSのとき 82 testBannerUnitId = "ca-app-pub-3940256099942544/2934735716"; 83 } 84 return testBannerUnitId; 85}

Podfile
※2行目でiOSのバージョンを11に指定

txt

1# Uncomment this line to define a global platform for your project 2platform :ios, '11.0' 3 4# CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 7project 'Runner', { 8 'Debug' => :debug, 9 'Profile' => :release, 10 'Release' => :release, 11} 12 13def flutter_root 14 generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 unless File.exist?(generated_xcode_build_settings_path) 16 raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 end 18 19 File.foreach(generated_xcode_build_settings_path) do |line| 20 matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 return matches[1].strip if matches 22 end 23 raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24end 25 26require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 28flutter_ios_podfile_setup 29 30target 'Runner' do 31 use_frameworks! 32 use_modular_headers! 33 34 flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35end 36 37post_install do |installer| 38 installer.pods_project.targets.each do |target| 39 flutter_additional_ios_build_settings(target) 40 end 41end

●Runner.xcworkspace
※Deployment Targetを11に変更
イメージ説明

●pubspec.yaml

yaml

1name: testapp 2description: A new Flutter project. 3publish_to: 'none' # Remove this line if you wish to publish to pub.dev 4version: 1.0.0+1 5 6environment: 7 sdk: '>=2.12.0 <3.0.0' 8 9dependencies: 10 flutter: 11 sdk: flutter 12 13 google_mobile_ads: 14 cupertino_icons: ^1.0.2 15 16dev_dependencies: 17 flutter_test: 18 sdk: flutter 19flutter: 20 uses-material-design: true

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

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

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

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

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

hoshi-takanori

2021/06/19 22:54

その記事のコメント欄で聞いてみれば良いのでは。
guest

回答1

0

ベストアンサー

iOS Deployment Targetの設定が低すぎるんではないでしょうか。
Runner.xcworkspaceを開いてDeployment Target上げたり、Podfileの上部をいじってみてください。

投稿2021/06/20 11:16

hiroshihorie

総合スコア192

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

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

tantan1

2021/06/20 11:53

ご回答ありがとうございます。Runner.xcworkspaceのDeployment TargetやPodfileの2行目を9や11にバージョンを上げてみたのですがエラーが解消されませんでした。エラーメッセージが変わりましたので、記事内容も修正しております(ご教示いただいた変更作業も併せて追記しました)。エラーメッセージをみるとバージョン変更が反映されていないようにも見え、Android Studioを再起動してデバッグし直したりもしましたが変わりませんでした・・・。
hiroshihorie

2021/06/20 13:19

あ、null safetyのエラーに変わってますね。これは—no-sound-null-safetyオプション付けてビルドするか、null safety対応パッケージを使えば解決すると思います。
tantan1

2021/06/20 17:34

「flutter run --no-sound-null-safety」で実行できました。ありがとうございました。
hiroshihorie

2021/06/26 06:53 編集

✌???? --no-sound-null-safetyは無理やりnull safetyなしで実行するオプションなので長期的には完全にnull safetyに移行したほうが良いです。各種パッケージも移行中みたいですご確認ください。
tantan1

2021/07/09 01:31

ありがとうございます。null safetyに移行できるよう、使用するパッケージについて考えます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問