isar / isar/hive

App crash when running on Android Studio but works on Xcode

Open
#822 0 comments 0 reactions 0 assignees View on GitHub
problem
Dominant language
Dart
Stars
4.4k
Forks
449
PR merge metrics
No merged PRs in 30d

Description

**Steps to Reproduce**
When I run the app via Android Studio, the app crashes after the splash screen without throwing any error info, but if I run via Xcode, everything works well. Below is how I use Hive, the app crashes even before I actually use it.

Also in the Quick Start, it uses `await Hive.initFlutter();`, but I didn't find this method, it seems that only `Hive.init()` available?

**Code sample**
```
dependencies:
hive: ^2.0.4
hive_flutter: ^1.1.0

dev_dependencies:
build_runner: ^2.1.4
hive_generator: ^1.1.1
```

```
Hive.init((await getApplicationDocumentsDirectory()).path);

@HiveType(typeId: 1)
class UpdateRecord extends HiveObject {
@HiveField(0)
late String digest;

@HiveField(1)
late int bytesProgrammed;

@HiveField(2)
late String deviceID;
}

someFunc() {
final records = await Hive.openBox("updateRecords");
UpdateRecord? record = records.get(deviceID);
final digest = md5.convert(appletBytes + firmwareBytes).toString();
if (record == null || record.digest != digest) {
record = UpdateRecord()
..digest = digest
..deviceID = deviceID
..bytesProgrammed = 0;
records.put(deviceID, record);
}
}
```

**Version**
Flutter (Channel master, 2.6.0-12.0.pre.470, on macOS 11.6 20G165 darwin-x64, locale en-AU)
• Framework revision 9350a149a6
• Engine revision f9bd71bf13
• Dart version 2.15.0 (build 2.15.0-250.0.dev)

Xcode Version 13.0 (13A233)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.