Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build failed when Integrate Flutter module into Android project #1671

Open
YanhqZ opened this issue May 8, 2024 · 10 comments
Open

build failed when Integrate Flutter module into Android project #1671

YanhqZ opened this issue May 8, 2024 · 10 comments

Comments

@YanhqZ
Copy link

YanhqZ commented May 8, 2024

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

Copy link

sync-by-unito bot commented May 8, 2024

➤ PM Bot commented:

Jira ticket: RDART-1023

@nirinchev
Copy link
Member

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.

@nirinchev nirinchev added the More-information-needed More information is needed to progress. The issue will close automatically in 2 weeks. label May 8, 2024
@github-actions github-actions bot removed the More-information-needed More information is needed to progress. The issue will close automatically in 2 weeks. label May 8, 2024
@YanhqZ
Copy link
Author

YanhqZ commented May 8, 2024

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
Copy link

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
Copy link
Member

That error seems completely unrelated with the original issue.

@YanhqZ
Copy link
Author

YanhqZ commented May 15, 2024

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
Copy link
Author

YanhqZ commented May 20, 2024

any update?

@TimotejKovac
Copy link

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
Copy link
Author

YanhqZ commented Sep 27, 2024

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
Copy link

ryosoul commented Oct 12, 2024

Having the same problem on a MacOS project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants