MehdiChouag
MehdiChouag

Reputation: 33

Integrate Flutter into an existing project

I'd like to add Flutter into an existing Android application. The initial projet is really huge so I cannot use flutter create, I went on the FAQ but there's a lack of documentation for this.

Here is the exception I get from Gradle :

Could not resolve all files for configuration ':app:officialGooglePlayStoreDebugCompileClasspath'.
Failed to transform file 'flutter-x86.jar' to match attributes {artifactType=android-classes} using transform JarTransform
   Transform output file /Users/mch/project/app_flutter/build/app/intermediates/flutter/flutter-x86.jar does not exist.

Apparently flutter-x86.jar cannot be generated. I tried to copy-paste it from another flutter project but the compilation just fail as well.

Upvotes: 0

Views: 2261

Answers (1)

Luke
Luke

Reputation: 6778

You should still run flutter create and then swap out the contents of the generated android and ios folders (via a submodule or whatever) with your existing projects. You will need to then manually port over all the flutter specific gradle tasks and config that are in the template projects to your projects in order for it to work.

You will also need to make sure that you add code to initialize the Flutter application and Plugin Registry, etc.

You will hit a lot of limitations though when trying to add Flutter to an existing app. #1 is that you will only be able to have one Flutter Activity, ViewController, View, etc in an application as a general rule.

It's something that will eventually work really well, and I'm not trying to dissuade you, but just be aware before starting.

Upvotes: 5

Related Questions