我刚刚将我的 flutter 项目包更新为空安全兼容,现在 Android Studio 希望我更新我的项目以使用最新版本的 Kodling Gradle 插件。但看不出在哪里可以改变这一点。我尝试过改变,"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"但这"org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10"没有效果。
我的build.grade文件如下所示:
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) …Run Code Online (Sandbox Code Playgroud) 最近我更新到了 flutter 2.5 和最新的 androids studio,并尝试将我的 flutter 项目编译到 android 设备。Android studio 向我抛出以下错误。如果我flutter run在终端中写入,则编译到 Android 设备没有问题。
猜测这肯定和android studio有关。我尝试降级到较早的 android studio 版本,但问题仍然存在。
我不确定这是什么插件,它看起来不像我在项目中使用的任何插件。
编辑:如果我将 flutter 从 2.5 降级到 2.0,我的项目将再次编译。所以问题出在flutter 2.5之内
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
../plugins/flutter/.pub-cache/hosted/pub.dartlang.org/photo_view-0.11.1/lib/src/core/photo_view_gesture_detector.dart:106:29: Error: The argument type 'PointerEvent' can't be assigned to the parameter type 'PointerDownEvent'.
- 'PointerEvent' is from 'package:flutter/src/gestures/events.dart' ('../plugins/flutter/packages/flutter/lib/src/gestures/events.dart').
- 'PointerDownEvent' is from 'package:flutter/src/gestures/events.dart' ('../plugins/flutter/packages/flutter/lib/src/gestures/events.dart').
super.addAllowedPointer(event);
Run Code Online (Sandbox Code Playgroud) 当我在 android studio 中为 sdk x86 arm(移动)编译我的 flutter 项目时,我突然收到以下错误。到目前为止一切都运行良好。昨天我将 flutter 升级到了最新版本,之后编译项目就没有问题了。但今天突然我莫名其妙地出现了这个错误。知道发生了什么吗?现在该怎么办?
\nLaunching lib/main.dart on sdk gphone x86 arm in debug mode...\nRunning Gradle task 'assembleDebug'...\nUnhandled exception:\nUnexpected Kernel SDK Version 72c1995001 (expected 7c8c6b3053).\n#0 BinaryBuilder._readAndVerifySdkHash (package:kernel/binary/ast_from_binary.dart:523:7)\n#1 BinaryBuilder.readComponent.<anonymous closure> (package:kernel/binary/ast_from_binary.dart:555:7)\n#2 Timeline.timeSync (dart:developer/timeline.dart:163:22)\n#3 BinaryBuilder.readComponent (package:kernel/binary/ast_from_binary.dart:539:21)\n#4 IncrementalCompiler.prepareSummary (package:front_end/src/fasta/incremental_compiler.dart:1647:12)\n#5 IncrementalCompiler.ensurePlatformAndInitialize (package:front_end/src/fasta/incremental_compiler.dart:1138:23)\n<asynchronous suspension>\n#6 IncrementalCompiler.computeDelta.<anonymous closure> (package:front_end/src/fasta/incremental_compiler.dart:229:11)\n<asynchronous suspension>\n#7 IncrementalCompiler.compile (package:vm/incremental_compiler.dart:69:29)\n<asynchronous suspension>\n#8 FrontendCompiler.compile (package:frontend_server/frontend_server.dart:509:11)\n<asynchronous suspension>\n#9 listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1105:11)\n<asynchronous suspension>\nthe Dart compiler exited unexpectedly.\nthe Dart compiler exited unexpectedly.\nRun Code Online (Sandbox Code Playgroud)\n这是颤振医生的输出:
\n/Users/thanos/Desktop/Development/flutter_2_0_1/bin/flutter doctor --verbose\n[\xe2\x9c\x93] Flutter (Channel stable, 2.0.5, on macOS …Run Code Online (Sandbox Code Playgroud) 是否可以从应用程序内发送通知而不是 Firebase 上的云功能?原因是,我想做类似的事情:FCM Push Notifications for Flutter,他们有这个功能将被部署到firebase:
export const sendToTopic = functions.firestore
.document('puppies/{puppyId}')
.onCreate(async snapshot => {
const puppy = snapshot.data();
const payload: admin.messaging.MessagingPayload = {
notification: {
title: 'New Puppy!',
body: `${puppy.name} is ready for adoption`,
icon: 'your-icon-url',
click_action: 'FLUTTER_NOTIFICATION_CLICK' // required only for onResume or onLaunch callbacks
}
};
return fcm.sendToTopic('puppies', payload);
});
Run Code Online (Sandbox Code Playgroud)
此方法在 firebase 云功能上按预期工作,但是我需要路径
.document('puppies/{puppyId}')
Run Code Online (Sandbox Code Playgroud)
动态取决于用户所在的聊天室,因此每次发送新消息时他都会收到通知,因此“chatroom22”将是一个变量:
.document('chatroom22/{roomId}')
Run Code Online (Sandbox Code Playgroud)
那么是否可以在应用程序代码中执行此操作,或者可以在已部署的函数中执行此操作?
回应道格史蒂文森的回答
好的,这是有道理的,并且有效。但是,现在每个人都会收到通知。我只希望给定聊天室中的人收到通知。我试过这样的事情,其中用户设备令牌保存给给定的聊天室,然后我想通知所有这些令牌:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().functions);
var newData;
exports.myTrigger = functions.firestore.document('messages/{messageId}/room/{roomId}/message/{messageId2}').onCreate(async …Run Code Online (Sandbox Code Playgroud) flutter google-cloud-functions firebase-cloud-messaging google-cloud-firestore
在发布模式下,当我运行我的应用程序时,如果我让应用程序在后台运行大约 30 秒并将应用程序带到前台,我会收到错误日志:
2020-07-24 23:12:14.473633+0200 myTest[11229:3284265] Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
2020-07-24 23:12:14.608936+0200 myTest[11229:3284265] Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service
2020-07-24 23:13:06.713676+0200 myTest[11229:3284265] dnssd_clientstub read_all(15) DEFUNCT
2020-07-24 23:13:06.713798+0200 myTest[11229:3284265] [VERBOSE-2:FlutterObservatoryPublisher.mm(131)] Could not register as server for FlutterObservatoryPublisher. Check your network settings and relaunch the application.
2020-07-24 23:13:06.733470+0200 myTest[11229:3285031] [] nw_read_request_report [C1] Receive failed with error "Software caused connection abort"
2020-07-24 23:13:06.733962+0200 myTest[11229:3285031] [] nw_read_request_report [C5] Receive failed with error …Run Code Online (Sandbox Code Playgroud)