简体   繁体   中英

How to use the same package name android app in two different build variants but their resource is different

I'm developing an application, I have two variants, one that makes the app blue and the other the app red, but I wanted to use the same package name for both, but when I changed variants, they would come with their respective colors.

example: I have the Carro Azul app that I have a variant build with package name com.carroazul, after that I create another variant build that will be installed over the original one because there are already users using the original Carro Azul, in this new build I want to create the same project but just change the colors of resources that are from blue to red but keep the same package name, when I'm in the blue build it will get the blue colors when I'm in the red build it gets the red colors keeping the same package name for one to be able to overwrite the other.

The way in general to do this is to make the code that uses the resource in a module. Then have your application module (you'll have two, one for each flavor) override the resources (by just placing a resource with the same name in that module). I'm more concerned about the same name part- on the Play Store only a single app can use the same package name. So you can't have two listings with the same name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM