Reputation: 8222
I'm working with flutter on an application (only android for now) which can be downloaded from Google Play. I have installed the released app on my phone. However, whenever I launch the debug on my device with android studio, it is deleting the released version. What I would want is having both apps at the same time, like "App" and "App_debug" on my device.
How can I set up my project so there is no conflict between the debug and the release app ?
Thank you.
Upvotes: 9
Views: 2399
Reputation: 1315
What're you looking for is called flavors
. You can check out more info about it in the flutter official docs or checking out these packages:
Upvotes: 2
Reputation: 8222
I managed to found a solution (only for android).
To not delete the "released App" download from Google Play, I add these lines in the file android/app/build.gradle
:
android {
buildTypes {
// ------ Start Changes -----
debug {
applicationIdSuffix ".debug"
}
// ----- End Changes -----
}
}
In that way the package will be com.example.app
for a release app and com.example.app.debug
for my debug app and there is no conflict anymore.
However I also wanted a different app name so I can differenciate both apps. To do so I followed this comment:
In the file android/app/src/main/AndroidManifest.xml
I made this change:
<manifest ...>
<application
// before : android:label="App"
android:label="@string/app_name" // <- After my changes
>
</application>
</manifest>
Then to set up the name for the release app, create or modify the file android/app/src/main/res/values/string.xml
:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">App</string>
</resources>
And for the debug version, create or modify the file android/app/src/debug/res/values/string.xml
:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">App Debug</string>
</resources>
Upvotes: 13