我们最近在使用 Android 的 Room 数据库时遇到了一些问题。
崩溃只发生在某些用户身上,但我无法在我的测试设备或模拟器上重现它。(这有时也会发生在 Firebase 测试设备上)
有一些例外似乎都是相关的。
所有这些异常都发生在我们由 Room 生成的 Dao 的不同行中。
(无论是查询、插入、更新还是删除)。
CursorWindowAllocationException: Cursor window allocation of 2048 kb failed.
IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: ‘/whatever/database’
SQLiteDiskIOException: disk I/O error (code 266)
SQLiteDiskIOException: disk I/O error (code 778)
SQLiteDatabaseCorruptException: file is encrypted or is not a database (code 26)
SQLiteException: Failed to change locale for db ‘/whatever/database' to 'fr_FR'.
Run Code Online (Sandbox Code Playgroud)
我试过的:
这些方法都没有帮助,错误仍然存在。
该LiveData的查询是唯一一个这是不卸载默认的数据库执行者,因为我无法找到一个方法来做到这一点。我怀疑这可能是问题所在,但我不完全确定。
这是 LiveData …
我正在尝试创建的某个动画有一个奇怪的颤动问题。
我正在尝试将图像动画化到屏幕上。我希望它在 x 轴上移动,我也希望它慢慢淡入。
所以我想 -Positioned和Opacity,并用补间动画它们的价值。
Positioned和Opacity小部件都可以单独工作,但是当我将两者结合起来时 - 我得到了一个奇怪的动画,它只在一段时间(大约 3 秒)后开始绘制。
我尝试打印animation.value它似乎没问题,从0.0到慢慢爬升1.0- 但云朵在大约 3 秒后突然出现。
我尝试将它们分开到不同的控制器,认为这可能是罪魁祸首,但不是。
TLDR 视频:
这是小部件的代码:
import 'package:app/weather/widgets/CloudProperties.dart';
import 'package:flutter/widgets.dart';
class WeatherCloudWidget extends StatefulWidget {
final double sunSize;
final CloudProperties properties;
WeatherCloudWidget({Key key, this.properties, this.sunSize})
: super(key: key);
@override
State<StatefulWidget> createState() => _WeatherCloudWidget();
}
class _WeatherCloudWidget extends State<WeatherCloudWidget>
with TickerProviderStateMixin {
AnimationController controller;
AnimationController controller2;
Animation<double> position;
Animation<double> opacity; …Run Code Online (Sandbox Code Playgroud) 最近,当我尝试调试 android 测试仪器 APK 时,每次启动应用程序时,我都会在 logcat 中看到类似的内容
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function0() took 158.211ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function1() took 101.701ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function2() took 110.852ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function3() took 211.494ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function4() took 102.497ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function5() took 126.639ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function6() took 138.077ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function7() took 131.311ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function8() took 253.859ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function9() took 111.431ms
W/com.myapp: Verification of …Run Code Online (Sandbox Code Playgroud) 我有一个警报活动,它作为全屏通知意图从服务启动。问题是,有时,活动将保持黑色,直到我将其关闭再打开。
现在,虽然屏幕是黑色的,但视图会响应触摸
如果我尝试截取屏幕截图,我会突然看到活动,如果我关闭并再次打开屏幕,一切都会按预期进行。
我似乎无法在我的调试版本中重现这个,但它不时发生在我的“生产”版本中。(比方说 1/5 次)
它会发生在早上打盹之间,但绝不会在第一个闹钟响起时发生。(据我观察)
关于导致这种情况的原因或如何重现这种情况的任何想法都会有很大帮助。
诡异视频:
这基本上是我启动活动的方式:
val builder = NotificationCompat.Builder(context, NotificationChannels.CHANNEL_ALARM_SERVICE)
...
// set intent
val alarmIntent = Intent(context, AlarmActivity::class.java)
alarmIntent.putExtra(IntentExtras.KEY_ID, alarm.id)
builder.setFullScreenIntent(PendingIntent.getActivity(context, RequestCodes.REQUEST_CODE_ALARM_ACTIVITY, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT), true)
...
startForeground(...)
Run Code Online (Sandbox Code Playgroud)
这就是我在 Activity 的onCreate()方法中解锁屏幕的方式
public class ScreenUnlockerUtil {
public static void unlockScreen(BaseActivity activity) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
// in addition to flags
activity.setShowWhenLocked(true);
activity.setTurnScreenOn(true);
} else {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}
if …Run Code Online (Sandbox Code Playgroud) android alarmmanager android-notifications android-activity android-doze