M20
M20

Reputation: 1102

Flutter- using fastlane with android multi flavors

I am using Flutter with multi flavors. And I'm trying to automate the building of apk. I declared this lane:

lane:
  desc "build apk"
  lane :test_build_android_app do |options|
    gradle(task: "assembleProductionfirst", build_type: "Release" })
  end

when I run this lane, I get this error:

Compiler message: Error: Error when reading 'lib/main.dart': No such file or directory package:flutter_app/main.dart: Error: No 'main' method found. Try adding a method named 'main' to your program. Target kernel_snapshot failed: Exception: Errors during snapshot creation: null build failed.

I have several mains. So I need to run flutter build -t lib/first/main.dart

How can specify the flutter main path when using fastlane or gradlew?

Upvotes: 11

Views: 3723

Answers (1)

Thierry
Thierry

Reputation: 326

I had the same issue - using "flags" did the trick for me:

gradle( flavor: "my_flavor", task: "bundle", build_type: "Release", flags: "-Ptarget=lib/main_flavor.dart")

Upvotes: 31

Related Questions