Error while adding sqflite in a flutter project - Execution failed for task ':sqflite:parseDebugLocalResources'
theakhinabraham opened this issue · 2 comments
theakhinabraham commented
The app doesn't run when I add the sqflite
dependency to my flutter project. It shows the following error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':sqflite:parseDebugLocalResources'.
> Could not resolve all files for configuration ':sqflite:androidApis'.
> Failed to transform android.jar to match attributes {artifactType=android-platform-attr, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for PlatformAttrTransform: C:\Users\theak\AppData\Local\Android\sdk\platforms\android-33\android.jar.
> C:\Users\theak\AppData\Local\Android\sdk\platforms\android-33\android.jar
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 51s
This is the dependency that I have added to my pubspec.yaml
file:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
flutter_riverpod: ^2.4.10
flutter_svg: ^2.0.10+1
sqflite: ^2.0.0+4
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^3.0.1
flutter_launcher_icons: ^0.13.1
Here is my flutter doctor
output:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.16.9, on Microsoft Windows [Version 10.0.22621.3007], locale en-IN)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.8.6)
[√] Android Studio (version 2023.1)
[√] VS Code (version 1.87.1)
[√] Connected device (3 available)
[√] Network resources
• No issues found!
theakhinabraham commented
Error continues to persist. Cannot find help in Stack Overflow, GitHub, Gemini AI or Google.
We have switched from sqflite
to ObjectBox
database for the following reasons:
- Performance:
ObjectBox
is a NoSQL database, designed to store and retrieve objects directly.Sqflite
, on the other hand, is a relational database that requires convertingDart
objects to SQL queries. This conversion process can be slower, especially for complex queries. Benchmarks showObjectBox
outperformingsqflite
in CRUD operations by a significant margin [various sources]. - Ease of Use:
ObjectBox
uses a more intuitive object-oriented approach for interacting with data. You define your Dart classes andObjectBox
handles the underlying storage.Sqflite
requires writing SQL queries, which can be cumbersome and error-prone for developers unfamiliar with SQL. - Data Relationships:
ObjectBox
can automatically handle relationships between objects, reducing boilerplate code for managing complex data models.Sqflite
requires manual creation and management of foreign keys for relationships.
Error has been solved:
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Parameter format not correct -
Running Gradle task 'assembleDebug'... 83.5s
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app-debug.apk... 16.5s
Syncing files to device sdk gphone64 x86 64... 1,706ms
theakhinabraham commented
android sdk 33
was partially installed. Re-install and everything works fine (even sqflite
, but we will be using ObjectBox
)