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

[add-to-app] Support flavors in module assemble #27639

Closed
jelenalecic opened this issue Feb 7, 2019 · 4 comments
Closed

[add-to-app] Support flavors in module assemble #27639

jelenalecic opened this issue Feb 7, 2019 · 4 comments
Labels
a: existing-apps Integration with existing apps via the add-to-app flow t: gradle "flutter build" and "flutter run" on Android tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@jelenalecic
Copy link

So, as suggested here:
https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps
we have added our Flutter module in existing apps(both android and iOS).
It works good, ATM :D

And now, I have added targets in my flutter module(to support different ssl certificates for different environments), as suggested here:
https://iirokrankka.com/2018/03/02/separating-build-environments/

Currently, we're building flutter module like this(from host Jenkins script):

cd flutter_module
cd .android
./gradlew clean
./gradlew assembleRelease
 ./gradlew assembleDebug

My question is, how can I assemble certain flutter target?

In example listed above, they're using:

flutter run -t lib/main_dev.dart
flutter run -t lib/main_prod.dart

...but how can I build this target from host app?

Jelenas-MacBook-Pro:flutter-comment-wall jelenalecic$ flutter doctor -v
[✓] Flutter (Channel master, v1.2.1-pre.66, on Mac OS X 10.13.6 17G4015, locale en-US)
    • Flutter version 1.2.1-pre.66 at /Users/jelenalecic/projects/flutter
    • Framework revision 496ddc580c (5 days ago), 2019-02-02 16:23:39 -0800
    • Engine revision 15f2b92cce
    • Dart version 2.1.1 (build 2.1.1-dev.3.2 71bee8f05e)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/jelenalecic/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    • ios-deploy 1.9.4
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 31.3.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

@dnfield

@wouterhardeman
Copy link

Based on this line I think this can be done by setting the target in .android/Flutter/build.gradle like this:

flutter {
    source '../..' // this line should already be there
    target 'lib/main_prod.dart'
}

You would have to do that manually. It would be nice to be able to easily configure this in the build types in the build.gradle of the existing Android app.

@zoechi zoechi added tool Affects the "flutter" command-line tool. See also t: labels. t: gradle "flutter build" and "flutter run" on Android a: existing-apps Integration with existing apps via the add-to-app flow labels Feb 7, 2019
@zoechi zoechi added this to the Goals milestone Feb 7, 2019
@dnfield
Copy link
Contributor

dnfield commented Feb 7, 2019

I'm not as sure about how this works on the Android side, @matthew-carroll or @xster might know

@jmagman jmagman added this to Awaiting triage in Add-to-app - Android tool review Jan 9, 2020
@jmagman jmagman added this to Awaiting triage in Tools - Gradle review Jan 10, 2020
@tvolkert tvolkert changed the title Adding Flutter module to existing apps - Flavors - Assemble certain target, to support flutter module 'flavors' [add-to-app] Support flavors in module assemble Jan 10, 2020
@blasten
Copy link

blasten commented Jan 18, 2020

This already supported in add-to-app. You can add flavors to your host app. From the host app, you can use Android studio to pick the flavor of your preference: https://developer.android.com/studio/build

@blasten blasten closed this as completed Jan 18, 2020
Add-to-app - Android tool review automation moved this from Awaiting triage to Engineer reviewed Jan 18, 2020
Tools - Gradle review automation moved this from Awaiting triage to Engineer reviewed Jan 18, 2020
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: existing-apps Integration with existing apps via the add-to-app flow t: gradle "flutter build" and "flutter run" on Android tool Affects the "flutter" command-line tool. See also t: labels.
Projects
Tools - Gradle review
  
Engineer reviewed
Add-to-app - Android tool review
  
Engineer reviewed
Development

No branches or pull requests

5 participants