LoginSignup
0
1

More than 1 year has passed since last update.

flutter設定備忘録

Last updated at Posted at 2021-06-12

flutterで直面したエラーの備忘録を記しておく

Flutter 2.2.1 
firebase_core: "^0.7.0"
cloud_firestore: "^0.16.0+1"

Firebaseの初期化エラー

core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()

以下のようにInitializeする。この時Saveだけでなくアプリを再起動させることが重要。ここでハマった。

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  FirebaseFirestore firestore = FirebaseFirestore.instance;

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    CollectionReference collectionReference = firestore.collection('users');
    return MaterialApp(
          ・・・・・
)

iosのバージョンエラー

Error output from CocoaPods:
↳
[!] Automatically assigning platform `iOS` with version `9.0` on target `Runner` because no platform was
specified. Please specify a platform for this target in your Podfile. See
`https://guides.cocoapods.org/syntax/podfile.html#platform`.

Error running pod install

ios>Podfileを開いて以下のように編集。この時 Podfile.lockがあったら消しておく。

# Uncomment this line to define a global platform for your project
platform :ios, '14.5'

flutter run時のエラー

Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:
- package:・・・・・
- package:・・・・・
- package:・・・・・

For solutions, see https://dart.dev/go/unsound-null-safety

これがAndroid Stadioで発生している場合は、
Run > Edit Configurationを選択して
Additional run args:の項目に --no-sound-null-safetyを設定する。

上記のエラーが出るときはpluginで Legacyを使用している場合に発生する。これはflutterの最新がnullを受け付けなくなっているので Null Saftyの方を使用する。

スクリーンショット 2021-06-12 22.40.42.png

 コンパイルエラー

1/android/src/main/java/io/flutter/plugins/firebase/auth/FlutterFirebaseAuthPlugin.javaは推奨されないAPIを使用またはオーバーライドしています。
注意:詳細は、-Xlint:deprecationオプションを指定して再コンパイルしてください。

特に気にする必要はないが煩わしい際は以下を編集
android>app>build.gradle

minSdkVersion 23  (←ここを23にする)
targetSdkVersion 30

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