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
の方を使用する。
*** コンパイルエラー***
1/android/src/main/java/io/flutter/plugins/firebase/auth/FlutterFirebaseAuthPlugin.javaは推奨されないAPIを使用またはオーバーライドしています。
注意:詳細は、-Xlint:deprecationオプションを指定して再コンパイルしてください。
特に気にする必要はないが煩わしい際は以下を編集
android
>app
>build.gradle
minSdkVersion 23 (←ここを23にする)
targetSdkVersion 30