我看到了很多关于下面错误的问题:“[错误:flutter/runtime/dart_vm_initializer.cc(41)]未处理的异常:PlatformException(null-error,Host platform returned null value for non-null return value.,null,null)”但是所有的解决方案都没有解决我的问题,我已经按照所有的说明同上,添加依赖关系等等。我的构建。gradles是好的,但当我运行我仍然得到错误。一个月前这对我很有效,但现在我不这样做了; I don’我不知道这个月发生了什么事。
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...
Parameter format not correct -
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app-debug.apk...
Debug service listening on ws://127.0.0.1:50498/Z0uovONnF5A=/ws
Syncing files to device AOSP on IA Emulator...
E/flutter ( 8435): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(null-error, Host platform returned null value for non-null return value., null, null)
E/flutter ( 8435): #0 FirebaseCoreHostApi.optionsFromResource (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:248:7)
E/flutter ( 8435): <asynchronous suspension>
E/flutter ( 8435): #1 MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:89:25)
E/flutter ( 8435): <asynchronous suspension>
E/flutter ( 8435): #2 Firebase.initializeApp (package:firebase_core/src/firebase.dart:43:31)
E/flutter ( 8435): <asynchronous suspension>
E/flutter ( 8435): #3 main (package:kp_app/main.dart:8:3)
E/flutter ( 8435): <asynchronous suspension>
E/flutter ( 8435):
这是我的主要。 dart 你可以看到我已经按照指示,我这样做上个月没有问题这个月我再试一次,问题
import 'package:easy_localization/easy_localization.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
await EasyLocalization.ensureInitialized();
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark));
runApp(EasyLocalization(
supportedLocales: const [
Locale('en'),
Locale('ar'),
Locale('es'),
Locale('fr'),
Locale('de'),
Locale('it'),
Locale('pt'),
Locale('ru'),
Locale('zh'),
Locale('ja'),
Locale('hi'),
Locale('sw')
],
path: 'assets/translations',
fallbackLocale: const Locale('en'),
//Default language
startLocale: const Locale('en'),
useOnlyLangCode: true,
child: const NewApp(),
));
}
class NewApp extends StatelessWidget {
const NewApp({super.key});
@override
Widget build(BuildContext context) {
return Container(
color: Colors.blue,
child: const Center(child: Text('My New APp')),
);
}
}
这是我的应用程序级别的build.gradle,正如你所看到的,它是完整的
//plugins {
// id "com.android.application"
// id "kotlin-android"
// id "dev.flutter.flutter-gradle-plugin"
// id '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 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"
apply plugin: 'com.google.gms.google-services'
//apply plugin: 'dev.flutter.flutter-gradle-plugin'
android {
namespace "com.prowebsolutions.kp_app"
compileSdkVersion 33
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.prowebsolutions.kp_app"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 28
//noinspection OldTargetApi
targetSdkVersion 31
// targetSdkVersion flutter.targetSdkVersion
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 platform('com.google.firebase:firebase-bom:32.3.1')
implementation 'com.google.firebase:firebase-analytics'
}
这也是我的项目级构建。
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.4.0'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
1条答案
按热度按时间e4yzc0pl1#
你好是谷歌服务版本尝试降级到4.3.15其他解决方案是迁移到buildscript到插件块检查下:
文件-> android/settings.gradle
文件-> android/build.gradle
文件-> android/app/build.gradle
文件-> android/local.properties
最后在
flutter pub get --no-example
之后执行flutter clean
并检查
google-services.json
文件