Flutter- using fastlane with android multi flavors
Asked Answered
S

1

11

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?

Sparge answered 22/1, 2020 at 11:52 Comment(3)
What OS are you using? and are you trying to use a CI platform? and are you using the command from the root of your folder's project?Anthodium
Linux OpenSuse, JenkinsSparge
can you post your 'lib/first/main.dart' ?Anthodium
F
31

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")

Fennel answered 4/2, 2020 at 18:6 Comment(3)
Can we do the same for fastlane's gym lane for iOS?Elevator
@RohanTaneja for IOS you can combine "scheme" and "configuration"Magnus
Love you man! Using Gradle flags are indeed the way to go. Here you can find all gradle related actions: docs.fastlane.tools/actions/gradleMariandi

© 2022 - 2024 — McMap. All rights reserved.