Ker*_*kay 16 firebase flutter google-cloud-firestore
我刚刚使用 firebase 安装了 flutter,但是在添加到数据库时出现以下错误
\n未找到 com.google.android.gms.providerinstaller.dynamite 的本地模块描述符类。\nI/DynamiteModule(10303):考虑本地模块 com.google.android.gms.providerinstaller.dynamite:0 和远程模块 com.google。 android.gms.providerinstaller.dynamite:0\nW/ProviderInstaller(10303):无法加载providerinstaller模块:找不到可接受的模块com.google.android.gms.providerinstaller.dynamite。本地版本为0,远程版本为0。
\n主程序.dart
\nimport 'package:cloud_firestore/cloud_firestore.dart';\nimport 'package:firebase_core/firebase_core.dart';\nimport 'package:flutter/material.dart';\nimport 'firebase_options.dart';\n\n\nFuture<void>main()async{\n WidgetsFlutterBinding.ensureInitialized();\n await Firebase.initializeApp(\n options: DefaultFirebaseOptions.android,\n );\n runApp(MyApp());\n}\n\nclass MyApp extends StatelessWidget {\n const MyApp({Key? key}) : super(key: key);\n\n @override\n Widget build(BuildContext context) {\n return MaterialApp(\n home: Iskele(),\n );\n }\n}\nclass Iskele extends StatefulWidget {\n const Iskele({Key? key}) : super(key: key);\n\n @override\n State<Iskele> createState() => _IskeleState();\n}\n\nclass _IskeleState extends State<Iskele> {\n TextEditingController t1 = TextEditingController();\n TextEditingController t2 = TextEditingController();\n contentAdd() {\n FirebaseFirestore.instance.collection('contents').doc("newcontent").set({\n 'title': t1.text,\n 'content': t2.text,\n });\n }\n @override\n Widget build(BuildContext context) {\n return Scaffold(\n body: Container(\n margin: EdgeInsets.all(30),\n child: Center(child: Column(mainAxisAlignment: MainAxisAlignment.center,children: [\n TextField(controller: t1,),\n TextField(controller: t2,),\n Row(mainAxisAlignment: MainAxisAlignment.center,children: [\n ElevatedButton(onPressed: contentAdd, child: Text("Add")),\n\n ],)\n ],),),\n\n ),\n );\n }\n}\nRun Code Online (Sandbox Code Playgroud)\npubspec.yaml
\nname: hadihayirlisi\ndescription: A new Flutter project.\n\n# The following line prevents the package from being accidentally published to\n# pub.dev using `flutter pub publish`. This is preferred for private packages.\npublish_to: 'none' # Remove this line if you wish to publish to pub.dev\n\n# The following defines the version and build number for your application.\n# A version number is three numbers separated by dots, like 1.2.43\n# followed by an optional build number separated by a +.\n# Both the version and the builder number may be overridden in flutter\n# build by specifying --build-name and --build-number, respectively.\n# In Android, build-name is used as versionName while build-number used as versionCode.\n# Read more about Android versioning at https://developer.android.com/studio/publish/versioning\n# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.\n# Read more about iOS versioning at\n# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html\n# In Windows, build-name is used as the major, minor, and patch parts\n# of the product and file versions while build-number is used as the build suffix.\nversion: 1.0.0+1\n\nenvironment:\n sdk: '>=2.18.0 <3.0.0'\n\n# Dependencies specify other packages that your package needs in order to work.\n# To automatically upgrade your package dependencies to the latest versions\n# consider running `flutter pub upgrade --major-versions`. Alternatively,\n# dependencies can be manually updated by changing the version numbers below to\n# the latest version available on pub.dev. To see which dependencies have newer\n# versions available, run `flutter pub outdated`.\ndependencies:\n cloud_firestore: ^3.4.7\n firebase_core: ^1.22.0\n flutter:\n sdk: flutter\n\n\n # The following adds the Cupertino Icons font to your application.\n # Use with the CupertinoIcons class for iOS style icons.\n cupertino_icons: ^1.0.2\n\ndev_dependencies:\n flutter_test:\n sdk: flutter\n\n # The "flutter_lints" package below contains a set of recommended lints to\n # encourage good coding practices. The lint set provided by the package is\n # activated in the `analysis_options.yaml` file located at the root of your\n # package. See that file for information about deactivating specific lint\n # rules and activating additional ones.\n flutter_lints: ^2.0.0\n\n# For information on the generic Dart part of this file, see the\n# following page: https://dart.dev/tools/pub/pubspec\n\n# The following section is specific to Flutter packages.\nflutter:\n\n # The following line ensures that the Material Icons font is\n # included with your application, so that you can use the icons in\n # the material Icons class.\n uses-material-design: true\n\n # To add assets to your application, add an assets section, like this:\n # assets:\n # - images/a_dot_burr.jpeg\n # - images/a_dot_ham.jpeg\n\n # An image asset can refer to one or more resolution-specific "variants", see\n # https://flutter.dev/assets-and-images/#resolution-aware\n\n # For details regarding adding assets from package dependencies, see\n # https://flutter.dev/assets-and-images/#from-packages\n\n # To add custom fonts to your application, add a fonts section here,\n # in this "flutter" section. Each entry in this list should have a\n # "family" key with the font family name, and a "fonts" key with a\n # list giving the asset and other descriptors for the font. For\n # example:\n # fonts:\n # - family: Schyler\n # fonts:\n # - asset: fonts/Schyler-Regular.ttf\n # - asset: fonts/Schyler-Italic.ttf\n # style: italic\n # - family: Trajan Pro\n # fonts:\n # - asset: fonts/TrajanPro.ttf\n # - asset: fonts/TrajanPro_Bold.ttf\n # weight: 700\n #\n # For details regarding fonts from package dependencies,\n # see https://flutter.dev/custom-fonts/#from-packages\nRun Code Online (Sandbox Code Playgroud)\n建造等级(项目)
\nbuildscript {\n ext.kotlin_version = '1.6.10'\n repositories {\n google()\n mavenCentral()\n }\n\n dependencies {\n classpath 'com.android.tools.build:gradle:7.1.2'\n classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"\n classpath 'com.google.gms:google-services:4.3.13'\n }\n}\n\nallprojects {\n repositories {\n google()\n mavenCentral()\n }\n}\n\nrootProject.buildDir = '../build'\nsubprojects {\n project.buildDir = "${rootProject.buildDir}/${project.name}"\n}\nsubprojects {\n project.evaluationDependsOn(':app')\n}\n\ntask clean(type: Delete) {\n delete rootProject.buildDir\n}\nRun Code Online (Sandbox Code Playgroud)\n构建等级(应用程序)
\ndef localProperties = new Properties()\ndef localPropertiesFile = rootProject.file('local.properties')\nif (localPropertiesFile.exists()) {\n localPropertiesFile.withReader('UTF-8') { reader ->\n localProperties.load(reader)\n }\n}\n\ndef flutterRoot = localProperties.getProperty('flutter.sdk')\nif (flutterRoot == null) {\n throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")\n}\n\ndef flutterVersionCode = localProperties.getProperty('flutter.versionCode')\nif (flutterVersionCode == null) {\n flutterVersionCode = '1'\n}\n\ndef flutterVersionName = localProperties.getProperty('flutter.versionName')\nif (flutterVersionName == null) {\n flutterVersionName = '1.0'\n}\n\napply plugin: 'com.android.application'\napply plugin: 'kotlin-android'\napply plugin: 'com.google.gms.google-services'\napply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"\n\nandroid {\n compileSdkVersion flutter.compileSdkVersion\n ndkVersion flutter.ndkVersion\n\n compileOptions {\n sourceCompatibility JavaVersion.VERSION_1_8\n targetCompatibility JavaVersion.VERSION_1_8\n }\n\n kotlinOptions {\n jvmTarget = '1.8'\n }\n\n sourceSets {\n main.java.srcDirs += 'src/main/kotlin'\n }\n\n defaultConfig {\n // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).\n applicationId "com.example.hadihayirlisi"\n // You can update the following values to match your application needs.\n // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.\n minSdkVersion 21\n targetSdkVersion flutter.targetSdkVersion\n versionCode flutterVersionCode.toInteger()\n versionName flutterVersionName\n }\n\n buildTypes {\n release {\n // TODO: Add your own signing config for the release build.\n // Signing with the debug keys for now, so `flutter run --release` works.\n signingConfig signingConfigs.debug\n }\n }\n}\n\nflutter {\n source '../..'\n}\n\ndependencies {\n implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"\n implementation platform('com.google.firebase:firebase-bom:30.2.0')\n implementation 'com.google.firebase:firebase-analytics'\n}\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
25402 次 |
| 最近记录: |