gpt4 book ai didi

android - MissingPluginException(在 Android 上未找到 channel plugins.flutter.io/firebase_core 上的 Firebase#initializeCore 方法的实现)

转载 作者:行者123 更新时间:2023-12-03 13:27:39 24 4
gpt4 key购买 nike

调用 Firebase.initializeApp() 时出现上述错误在我的 flutter 代码中。
我已经按照这里的文档: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
这是我的 flutter 代码:
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);
},
),
);
}
以下是我的 .gradle (app) 文件的相关部分:
plugins {
id "com.android.application"
id "com.google.gms.google-services"
id "kotlin-android"
id "kotlin-android-extensions"
}

这是我的项目 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
}

和我的应用程序类扩展:
class MyApp : FlutterApplication() {
override fun onCreate() {
super.onCreate()
}
}
据我所知,我根据文档正确地完成了所有操作。

最佳答案

将 minifyEnabled 和 shrinkResources 设置为 false 可以修复它,但为什么呢?我不知道。如果有人知道请写评论。

buildTypes {       
release {
signingConfig signingConfigs.release
minifyEnabled false
shrinkResources false
}
}

关于android - MissingPluginException(在 Android 上未找到 channel plugins.flutter.io/firebase_core 上的 Firebase#initializeCore 方法的实现),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63462069/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com