我们可以合并两个android源并使用产品样式吗? [英] Can we merge two android source and use product flavors?

查看:93
本文介绍了我们可以合并两个android源并使用产品样式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个具有相同源代码的Android项目,但两个应用程序中的应用程序图标更改.但是我没有使用产品风味.现在我需要合并源代码并使用产品风味.这样有可能吗?

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?

推荐答案

在此 ,基本上,您需要做的是创建一个文件夹结构,该结构镜像main-> res-> mipmap结构,将main替​​换为您的风味名称,如下所示:

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

编辑

合并两个项目的源代码后,您需要在gradle配置中创建2种不同的产品样式,并将清单占位符用于应用名称和程序包之类的内容:

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"
        }
    }

在您的清单中

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="${applicationId}">

如果代码内容相同,则应该没有问题,在准备发行版apk时只需选择正确的buildVariant和密钥库即可.

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.

这篇关于我们可以合并两个android源并使用产品样式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆