Can we merge two android source and use product flavors?

匆匆过客 提交于 2020-01-22 02:04:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!