realm / realm-dart

Realm is a mobile database: a replacement for SQLite & ORMs.
Apache License 2.0
768 stars 87 forks source link

build failed when Integrate Flutter module into Android project #1671

Open YanhqZ opened 6 months ago

YanhqZ commented 6 months ago

What happened?

Task :realm:downloadRealmBinaries FAILED Changing current working directory to: /Users/yhq Could not find package "realm". Did you forget to add a dependency?

Task :realm:runMetrics FAILED Changing current working directory to: /Users/yhq Could not find package "realm". Did you forget to add a dependency?

Repro steps

1.create a flutter module project(ep.realm_flutter_modules) and add realm dependency ` dependencies: flutter: sdk: flutter

...

realm: ^2.2.1 ` 2.create a android project(ep.RealmAddToApp) and follow the doc

3.run. then see build failed...

Version

3.19.3

What Atlas Services are you using?

Local Database only

What type of application is this?

Flutter Application

Client OS and version

Android Studio Iguana | 2023.2.1

Code snippets

Host App(RealmAddToApp) flutter_settings.gradle setBinding(new Binding(["gradle": this])) evaluate(new File( settingsDir.parentFile, "realm_flutter_modules/.android/include_flutter.groovy" ))

settings.gradle.kts //... apply { from("flutter_settings.gradle") } //... build.gradle.kts(app) //... dependencies { //... implementation(project(":flutter")) //... } //...

Stacktrace of the exception/crash you're getting

No response

Relevant log output

No response

sync-by-unito[bot] commented 6 months ago

➤ PM Bot commented:

Jira ticket: RDART-1023

nirinchev commented 6 months ago

Sounds like you can reproduce this with a brand new project, do you mind uploading/sharing that so that we can look into what's happening?

The repro steps are pretty much the standard install steps and those work, so there's likely something subtle in your setup that's hitting a corner case we didn't guard against.

YanhqZ commented 6 months ago

Sounds like you can reproduce this with a brand new project, do you mind uploading/sharing that so that we can look into what's happening?

The repro steps are pretty much the standard install steps and those work, so there's likely something subtle in your setup that's hitting a corner case we didn't guard against.

https://github.com/yanhq0719/flutter_module.git https://github.com/yanhq0719/RealmAddToApp.git

akshay-thence commented 5 months ago

I am also getting this error

Launching lib/main_development.dart on Redmi Note 8 in debug mode...
Package realm not found in dependencies. Add realm package to your pubspec.yaml
-t, --target-os-type    The target OS to install binaries for.
                        [android, ios, linux, macos, windows]

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':realm:downloadRealmBinaries'.
> Process 'command '/Users/mac/development/flutter/bin/dart'' finished with non-zero exit value 64
nirinchev commented 5 months ago

That error seems completely unrelated with the original issue.

YanhqZ commented 5 months ago

That error seems completely unrelated with the original issue.

maybe the realm gradle task problem. the [runMetrics] and [downloadRealmBinaries] workingDir point to wrong path.

YanhqZ commented 5 months ago

any update?

TimotejKovac commented 2 months ago

We were experiencing the same issue when trying to use flutter as a module. We solved the issue by locking the version of realm, copying and modifying realm's build.gradle (we specified correct relative paths for workingDir) and then creating a task that would run before each build that overrides the generated realm's build.gradle (in .pub-cache) with our modified one.

It would be really nice if realm had better support for this. Acquiring the path for workingDir via an environmental variable or reading it from local.properties.

YanhqZ commented 1 month ago

We were experiencing the same issue when trying to use flutter as a module. We solved the issue by locking the version of realm, copying and modifying realm's build.gradle (we specified correct relative paths for workingDir) and then creating a task that would run before each build that overrides the generated realm's build.gradle (in .pub-cache) with our modified one.

It would be really nice if realm had better support for this. Acquiring the path for workingDir via an environmental variable or reading it from local.properties.

Thanks for your comment, we adopt simlar way (fork repository and modifying realm's build.gradle) to solve this issue in the past period. Fortunately, at this moment we had achieved whole flutter-developed application so wo can get rid of this. But i believe before realm team proposing a solution, your solution should be the best answer

ryosoul commented 3 weeks ago

Having the same problem on a MacOS project.