问题
I have two android project with same source code only app icon change in both app. But i don't have use product flavor. now i need to merge source code and use product flavor. so it is possible?
回答1:
What you are looking for has been answered here, basically what you need to do is to create a folder structure that mirrors the main->res->mipmap structure replacing main with your flavour name like this:
-src
-main
-res
-app_one
-res
-mimap-*
-ic_launcher.png
-app_two
-res
-mimap-*
-ic_launcher.png
EDIT
After merging the source code of the 2 projects you need to create 2 different product flavours in your gradle configuration and use the manifest placeholders for things like the app name and package:
productFlavors {
app_one {
applicationId "xxx.yyy.zzz"
}
app_two {
applicationId "aaa.bbb.ccc"
}
}
And in your manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="${applicationId}">
If the code content is the same you shouldn't have any issue, just select the right buildVariant and keystore when preparing the release apk.
来源:https://stackoverflow.com/questions/58823587/can-we-merge-two-android-source-and-use-product-flavors