'How to switch from develop interface to final user app in Android?
I have a textview and a google maps in my app that are usefull when the app is developed, but for final user i want to hide them, what is the best way to do that?
I was thinking in
.setVisibility(View.INVISIBLE);
and next add an "if" whenever the google maps and textview are used but i think this a terrible bad practice.
any suggetions?
Solution 1:[1]
Let's say there are Two scenarios, Development (debug build) & Production (Final or Release build)
Now here with your need you wanted to hide Google map & Textview in case of production build and keep Google map and textview visible when you are developing, so for that you can try out below thing to achieve what you want
By default new project have only two buildTypes(release & debug) in build.gradle so by considering that here i am showcasing you solution hint in terms of code snippet
Approach 1
if (BuildConfig.DEBUG) {
// You can make google map and textview visible here
} else {
// You can make google map and textview invisible or gone here
}
Approach 2
if (BuildConfig.BUILD_TYPE.equals("debug")) {
// You can make google map and textview visible here
} else if (BuildConfig.BUILD_TYPE.equals("release")) {
// You can make google map and textview invisible or gone here
} else {
// behaviour you want by default or in case of other build types than
release or debug
}
Solution 2:[2]
It's not too uncommon for an app to have a set of features only available in debug mode. The trick is writing your architecture such that it's done cleanly. With visible items, you need to make sure you test in release mode not only that the elements aren't there, but that the removal of those elements doesn't break your layout (a common problem with RelativeLayout is that removing an element others are relative to breaks them).
I would consider not putting them in the main screen, but putting them in an overlay or secondary screen of some sort. That way you don't have to worry about UI problems in prod vs release, and only need to test that in prod you can't access that screen.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mobile Team ADR-Flutter |
| Solution 2 | Gabe Sechan |
