Tom*_*ila 15 android firebase flutter google-cloud-firestore flutter-dependencies
调用Firebase.initializeApp()
我的颤振代码时出现上述错误。我遵循了这里的文档:https : //firebase.flutter.dev/docs
这是我的 pubspec.yaml
dependencies:
flutter:
sdk: flutter
firebase_core: ^0.5.0
cloud_firestore: ^0.14.0
firebase_auth: ^0.18.0
fl_chart: ^0.11.0
snapping_sheet: ^2.0.0
flutter_svg: ^0.18.0
flutter_redux: ^0.6.0
strings: ^0.1.2
random_string: ^2.1.0
redux_thunk: ^0.3.0
# firebase_crashlytics: ^0.1.4+1
dotted_line: ^2.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
Run Code Online (Sandbox Code Playgroud)
这是我的颤振代码:
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
final store = Store<AppState>(AppState.reducer, initialState: AppState.initial(), middleware: [thunkMiddleware]);
runApp(
FutureBuilder(
future: Firebase.initializeApp(),
builder: (context, snapshot) {
// Check for errors
if (snapshot.hasError) {
log(snapshot.error.toString());
return Container(color: Colors.red);
}
// Once complete, show your application
if (snapshot.connectionState == ConnectionState.done) {
return StoreProvider<AppState>(
store: store,
child: MoollaApp(store: store),
);
}
// Otherwise, show something whilst waiting for initialization to complete
return Container(color: Colors.green);
},
),
);
}
Run Code Online (Sandbox Code Playgroud)
这是我的 .gradle (app) 文件的相关部分:
plugins {
id "com.android.application"
id "com.google.gms.google-services"
id "kotlin-android"
id "kotlin-android-extensions"
}
Run Code Online (Sandbox Code Playgroud)
这是我的项目gradle文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.3.72"
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0-alpha07'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
和我的应用程序类扩展:
class MyApp : FlutterApplication() {
override fun onCreate() {
super.onCreate()
}
}
Run Code Online (Sandbox Code Playgroud)
据我所知,我已根据文档正确完成了所有操作。
Pau*_*aul 11
许多 Firebase 软件包都包含本机代码。一般来说,任何带有本机代码的包都需要在设备上完全重置应用程序;意味着删除初始值并第一次执行本机代码:
完毕!
小智 6
如果不仔细检查整个项目,很难准确说出问题所在,但这里有一些可能可以解决问题的操作。
flutter doctor
并验证一切是否按预期工作。flutter clean
后跟flutter pub get
.如果您仍然收到相同的错误,那么您可能在编辑配置文件之一时犯了错误。
<meta-data />
标签,因为这样做会导致上述错误。将 minifyEnabled 和 shrinkResources 设置为 false 可以修复它,但为什么呢?我不知道。如果有人知道请写评论。
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled false
shrinkResources false
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9939 次 |
最近记录: |