gpt4 book ai didi

android - 当使用发布 apk 时,某些代码已被 Dart AOT 编译器 (TFA) 删除

转载 作者:行者123 更新时间:2023-12-03 04:59:24 25 4
gpt4 key购买 nike

我想给一些 friend 一个我的项目的apk版本来测试它。
在我的 IDE 上,我的项目运行良好 ,可能是一些错误,但主要概念是可行的。

他们报告了一些在我这边没有发生的错误,所以我尝试了 发布apk 当我触发 一些具体方法出现此错误:

[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Attempt to execute code removed by Dart AOT
compiler (TFA)

this is the error message

触发此错误的方法是:
Future askFriends(String friendName) async {
print("Send FRIENDS Request");
print(friendName);
await _fs
.collection("Users")
.document(await pbd.getEmail(friendName))
.collection("FriendsRequest")
.document(await pbd.getUserName())
.setData({
"profilPicture": await pbd.getProfilePicture(),
"friendName": await pbd.getUserName(),
"friendEmail": currentUserEmail,
});
}

void acceptFriends(String friendName, String profilPicture) async {
var reference = randomAlphaNumeric(20);
String friendEmail = await pbd.getEmail(friendName);
String userName = await pbd.getUserName();
print("ADD FRIENDS");
await _fs
.collection("Users")
.document(currentUserEmail)
.collection("FriendsRequest")
.document(friendName)
.delete();
await _fs
.collection("Users")
.document(friendEmail)
.collection("Friends")
.document(userName)
.setData({
"profilPicture": await pbd.getProfilePicture(),
"friendName": userName,
"friendEmail": currentUserEmail,
"chatReference": reference,
});
await _fs
.collection("Users")
.document(currentUserEmail)
.collection("Friends")
.document(friendName)
.setData({
"profilPicture": profilPicture,
"friendName": friendName,
"friendEmail": friendEmail,
"chatReference": reference,
});
_fs.collection("PrivateChat").document(reference).setData({
"users": [userName, friendName]
});
_fs.collection("Users").document(currentUserEmail).updateData({
"friends": await pbd.getUserFriendsNumber(currentUserEmail) + 1,
});
_fs.collection("Users").document(friendEmail).updateData({
"friends": await pbd.getUserFriendsNumber(friendEmail) + 1,
});
}

同样在运行“Flutter run --release -v”时
关于 AOT 它只返回:
c:\src\flutter\bin\cache\artifacts\engine\common\flutter_patched_sdk_product/ --target=flutter -Ddart.developer.causal_async_stacks=true
-Ddart.vm.profile=false -Ddart.vm.product=true --bytecode-options=source-positions --aot --tfa --packages D:\Willy\myApp\Komeet\.packages
--output-dill D:\Willy\myApp\Komeet\.dart_tool\flutter_build\605851d98f347f3bc8bcbe0b131320ff\app.dill --depfile
D:\Willy\myApp\Komeet\.dart_tool\flutter_build\605851d98f347f3bc8bcbe0b131320ff\kernel_snapshot.d package:Komeet/main.dart
[+15101 ms] [+15122 ms] kernel_snapshot: Complete
[ +198 ms] [ +266 ms] invalidated build due to missing files:
c:\src\flutter\bin\cache\artifacts\engine\android-arm64-release\windows-x64\gen_snapshot
[ +600 ms] [ +509 ms] android_aot_release_android-arm64: Starting due to {InvalidatedReason.inputChanged, InvalidatedReason.inputMissing}
[ +1 ms] [ +6 ms] executing: c:\src\flutter\bin\cache\artifacts\engine\android-arm64-release\windows-x64\gen_snapshot
--causal_async_stacks --deterministic --snapshot_kind=app-aot-elf
--elf=D:\Willy\myApp\Komeet\.dart_tool\flutter_build\605851d98f347f3bc8bcbe0b131320ff\arm64-v8a\app.so --strip
D:\Willy\myApp\Komeet\.dart_tool\flutter_build\605851d98f347f3bc8bcbe0b131320ff\app.dill
[ +1 ms] [ ] aot_android_asset_bundle: Starting due to {InvalidatedReason.inputChanged}
[ +197 ms] [ +231 ms] aot_android_asset_bundle: Complete
[+10601 ms] [+10568 ms] android_aot_release_android-arm64: Complete
[ +198 ms] [ +245 ms] android_aot_bundle_release_android-arm64: Starting due to {InvalidatedReason.inputChanged}
[ +101 ms] [ +59 ms] android_aot_bundle_release_android-arm64: Complete
[ ] [ +82 ms] Persisting file store
[ +99 ms] [ +65 ms] Done persisting file store
[ +1 ms] [ +3 ms] build succeeded.

在 firestore 上写入 read 不是问题,因为 apk 中使用的许多方法都使用 Cloud Firestore 并且完全可以。

Flutter doctor

My Pubspec.yaml

Build.grade[APP-level]

Build.grade[Project-level]

我在网上只发现了一个类似的问题:
Attempt to execute code removed by Dart AOT compiler (TFA), how to troubleshoot this issue

于是我尝试删除构建目录,flutter clean,flutter pub缓存修复,重新新建一个flutter项目,导入我项目的所有组件。改变 flutter 的 channel 。

还写“Flutter clean”给这个警告。
Failed to remove build. A program may still be using a file in the directory or the directory itself. To find and stop such a program, see:
https://superuser.com/questions/1333118/cant-delete-empty-folder-because-it-is-used

我已按照说明进行操作,但没有任何改变。

谢谢你帮助我。

最佳答案

好的,所以我通过以下方式解决了这个问题:

- 将 flutter channel 更改为稳定

-更改内部版本号

-更改具体方法:

似乎( cloud firestore 有一些问题 (与 IDE 上的项目没有提供相同的结果)。

引用:https://github.com/FirebaseExtended/flutterfire/issues/1857

之前的方法:

Future askFriends(String friendName) async {
print("Send FRIENDS Request");
print(friendName);
await _fs
.collection("Users")
.document(await pbd.getEmail(friendName))
.collection("FriendsRequest")
.document(await pbd.getUserName())
.setData({
"profilPicture": await pbd.getProfilePicture(),
"friendName": await pbd.getUserName(),
"friendEmail": currentUserEmail,
});
}

void acceptFriends(String friendName, String profilPicture) async {
var reference = randomAlphaNumeric(20);
String friendEmail = await pbd.getEmail(friendName);
String userName = await pbd.getUserName();
print("ADD FRIENDS");
await _fs
.collection("Users")
.document(currentUserEmail)
.collection("FriendsRequest")
.document(friendName)
.delete();
await _fs
.collection("Users")
.document(friendEmail)
.collection("Friends")
.document(userName)
.setData({
"profilPicture": await pbd.getProfilePicture(),
"friendName": userName,
"friendEmail": currentUserEmail,
"chatReference": reference,
});
await _fs
.collection("Users")
.document(currentUserEmail)
.collection("Friends")
.document(friendName)
.setData({
"profilPicture": profilPicture,
"friendName": friendName,
"friendEmail": friendEmail,
"chatReference": reference,
});
_fs.collection("PrivateChat").document(reference).setData({
"users": [userName, friendName]
});
_fs.collection("Users").document(currentUserEmail).updateData({
"friends": await pbd.getUserFriendsNumber(currentUserEmail) + 1,
});
_fs.collection("Users").document(friendEmail).updateData({
"friends": await pbd.getUserFriendsNumber(friendEmail) + 1,
});
}

现在的方法:
Future askFriends(String friendName) async {
print("Send FRIENDS Request");
String userName = await pbd.getUserName();
String friendEmail = await pbd.getEmail(friendName);
String profilPicture = await pbd.getProfilePicture();
print(friendName);
await _fs
.collection("Users")
.document(friendEmail)
.collection("FriendsRequest")
.document(userName)
.setData({
"profilPicture": profilPicture,
"friendName": userName,
"friendEmail": currentUserEmail,
});
}

void acceptFriends(String friendName, String profilPicture) async {
var reference = randomAlphaNumeric(20);
String friendEmail = await pbd.getEmail(friendName);
String userName = await pbd.getUserName();
String userProfilPicture = await pbd.getProfilePicture();
int userFriends = await pbd.getUserFriendsNumber(currentUserEmail);
int friendFriends = await pbd.getUserFriendsNumber(friendEmail);
print("ADD FRIENDS");
await _fs
.collection("Users")
.document(currentUserEmail)
.collection("FriendsRequest")
.document(friendName)
.delete();
await _fs
.collection("Users")
.document(friendEmail)
.collection("Friends")
.document(userName)
.setData({
"profilPicture": userProfilPicture,
"friendName": userName,
"friendEmail": currentUserEmail,
"chatReference": reference,
});
await _fs
.collection("Users")
.document(currentUserEmail)
.collection("Friends")
.document(friendName)
.setData({
"profilPicture": profilPicture,
"friendName": friendName,
"friendEmail": friendEmail,
"chatReference": reference,
});
_fs.collection("PrivateChat").document(reference).setData({
"users": [userName, friendName]
});
_fs.collection("Users").document(currentUserEmail).updateData({
"friends": userFriends + 1,
});
_fs.collection("Users").document(friendEmail).updateData({
"friends": friendFriends + 1,
});
}

关于android - 当使用发布 apk 时,某些代码已被 Dart AOT 编译器 (TFA) 删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59909354/

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