我在flutter中编写了一个注册屏幕,我使用了Firebase,但我却遇到了这个错误,但在我的项目中,我在Android\App中有google-services.json。我不明白你为什么能帮我?我做了初始化和Firebase网站的东西
E/flutter(26694):[错误:flutter/lib/ui/ui_dart_state.cc(166)]未处理得异常:[core/not-initialized]Firebase未正确初始化.您是否已将“google-services.json”文件添加到项目中?
Main.Dart
import 'package:edebiyat_uygulamasi/giris.dart';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(App());
}
class App extends StatelessWidget {
// Create the initialization Future outside of `build`:
@override
Widget build(BuildContext context) {
return FutureBuilder(
// Initialize FlutterFire:
builder: (context, snapshot) {
// Check for errors
if (snapshot.hasError) {
debugPrint("something went wrong");
}
// Once complete, show your application
if (snapshot.connectionState == ConnectionState.done) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme:
ThemeData(primaryColor: Colors.white, errorColor: Colors.white),
home: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.purple,
appBar: AppBar(
title: Text("Engelsiz Edebiyat"),
),
body: GirisSayfasi(),
),
);
}
// Otherwise, show something whilst waiting for initialization to complete
return CircularProgressIndicator();
},
);
}
}
注册屏幕
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
FirebaseAuth _auth = FirebaseAuth.instance;
String _Email, _Sifre;
class GirisSayfasi extends StatefulWidget {
@override
_GirisSayfasiState createState() => _GirisSayfasiState();
}
class _GirisSayfasiState extends State<GirisSayfasi> {
@override
Widget build(BuildContext context) {
return Container(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
child: Text(
"E-posta",
style: TextStyle(fontSize: 22, color: Colors.white),
),
margin: EdgeInsets.only(top: 30, left: 30),
alignment: Alignment.topLeft,
),
Container(
child: TextField(
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderSide: BorderSide(color: Colors.white),
),
hintText: "Emailinizi Giriniz",
hintStyle: TextStyle(color: Colors.white),
),
onChanged: (String edeger) => _Email = edeger,
),
padding: EdgeInsets.only(left: 35, right: 35),
),
Container(
child: Text(
"Şifre",
style: TextStyle(fontSize: 22, color: Colors.white),
),
margin: EdgeInsets.only(top: 30, left: 30),
alignment: Alignment.topLeft,
),
Container(
child: TextField(
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderSide: BorderSide(color: Colors.white),
),
hintText: " Şifrenizi Giriniz",
hintStyle: TextStyle(color: Colors.white),
),
onChanged: (String sdeger) => _Sifre = sdeger,
),
padding: EdgeInsets.only(left: 35, right: 35),
),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
child: RaisedButton(
onPressed: HesapOlustur,
child: Text("Hesap Oluştur"),
color: Colors.white),
alignment: Alignment.center,
),
],
),
],
),
);
}
}
HesapOlustur() async {
UserCredential _credential = await _auth.createUserWithEmailAndPassword(
email: _Email, password: _Sifre);
}
pubspec.yaml
name: edebiyat_uygulamasi
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
firebase_auth: ^0.18.1+2
firebase_core: ^0.5.0+1
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
Android\BuildGradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Android\App\BuildGradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.edebiyat_uygulamasi"
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
}
在您的android/app/build.gradle
中放入下面的代码,我添加了这行apply插件:'com.google.gms.google-services'
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.edebiyat_uygulamasi"
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
看看是否管用。
我试图将我的Flitter应用程序与firebase连接,但我发现了这个错误。提前感谢:) 失败:生成失败,出现异常。 错误:配置根项目“android”时出现问题 无法解析配置: classpath的所有工件。无法解决com.google.gms: google-service: 4.3.8.所需:项目: > 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--deb
编辑:我刚刚意识到,即使是一个带有应用程序条的简单屏幕,也会发生这种情况 错误:任务“:app:checkdebugaarmadata”的执行失败 无法解析配置“:app:debugRuntimeClasspath”的所有文件。无法解析com。谷歌。firebase:firebase firestore:22.1.2。所需人员:项目:应用程序 无法解析com。谷歌。firebase:firebas
测试运行程序 导入org.junit.runner.runwith; 在此输入图像说明
我是Java新手,正在学习扫描仪。下面是我的代码,我相信我写的是正确的。我正在学习扫描仪,并且正在使用EclipseIDE。我犯了错误,我不知道为什么。非常感谢你的帮助。 在此处输入图像描述
我想在我的项目中使用谷歌分析和Firebase。我已经从Firebase控制台的设置中下载了google-services.json文件,但是在使用它之后,我无法支持Google Analytics。它向我展示了错误: 如何在同一个。json文件中配置两者? 从firebase仪表板下载的。json文件中缺少以下字段。
在salon_应用程序中运行“flatter pub get”…启动lib/main。iPhone 13上的dart处于调试模式…运行pod安装…运行Xcode构建…Xcode构建完成。20.3s无法从Xcode生成生成iOS应用程序错误输出:↳ objc[23537]:类amSupportUrlConnectionLegate在/usr/lib/libauthinstall中实现。动态库(0x1