多个应用程序使用不同的名称相同的code基多个、应用程序、不同、名称

2023-09-06 00:01:31 作者:回首已陌路

看完这篇文章,原以为有同样的问题 - 一个code的基础上,在Android上的两个应用程序

Reading this article, thought having the same problem - One code base, two applications on Android

我已经创建 testApp 一个应用程序,有一个像主题闪屏项目标志规则状态和/或事件

I have created an application testApp that has items like topics, splash screens, logos, charts, rules, statuses and/or events.

现在,我想不同的应用程序( testApp_USA testApp_Canada testApp_Australia ),并把它们在谷歌Play商店,这样,如果用户下载的应用程序,比方说, testApp_USA ,然后只有特定的项目该区域应显示如美国的闪屏,USA标识等。

Now, I want different applications (testApp_USA, testApp_Canada, testApp_Australia)from the same code base and put them on Google Play Store so that if user downloads the application, say, testApp_USA, then only the specific items to that region should be shown like splash Screen of USA, USA logos, etc..

所以,我想根据国家配置多个应用程序,然后根据用户下载的应用程序设置的项目作为默认值。

So I want to configure multiple applications according to countries and then set the items as defaults according to which application the user has downloaded.

presently ,我有一个单一的应用程序,它是所有地区和我堂堂多个条件来区分,或根据地区更改的项目。

Presently, I have a single application which is for all regions and I am imposing multiple conditions to distinguish or change the items according to the regions.

例如:

(在许多Java文件,我用的)

if(rule.contains("USA"))
{
 //Show splash screen of USA
}

(同样,在许多Java文件,我用的)

if(rule.contains("Australia"))
{
 //Show splash screen of Australia
}

这仅仅是一个项目了许多遍布code重复。考虑到所有,这将是多很多。

This is just a one item out of many repeated throughout code. Considering all, it will be lot more.

应该有更好的方式来创建的Andr​​oid不同的名称和设置多个应用程序。

There should be a better way to create multiple applications in android with different names and settings.

我知道, 的iOS 的可以让我轻松地更改应用程序名称和配置文件,以允许创建多个应用程序。但我不知道,或者这是不容易做到在Android code。

I know, iOS allows me to easily change the application name and profile to allow multiple apps to be created. But I don't know or this is not easy to do on the Android code.

我的问题:

是否可以创建不同的应用程序具有相同源$ C ​​$ c在机器人与项目不同的设置,并将它们发布到谷歌Play商店?如果是,如何设定这样的配置?

Is it possible to create different applications with the same source code in android with different settings of items and publish them to Google Play Store ? If YES, How to set such configuration ?

更新:

阅读这篇文章 - multiple-android-application-package-apk-files-from-single-source-$c$c

于是我想出了同样的想法 -

Then I came up with the same idea -

1)采取了一些保存有关要创建的应用程序类型的值的字符串变量。

1) Taking some string variable that holds values about which application type you want to create.

public static final String app_Name = "testApp_CANADA" ;

2)有多个的Andr​​oidManifest.xml 文件多个应用程序,您需要创建.apk文件的。

2) Have multiple AndroidManifest.xml files for multiple apps you need to create .apk for.

3)建立相应的发射活动,为每一个清单。

3) Create corresponding launcher activities for each manifest.

不过,再怎么有多个的Andr​​oidManifest.xml 在一个单一的应用程序文件?

But then how to have multiple AndroidManifest.xml files in a single app ?

更新:

我的第一个的Andr​​oidManifest.xml 是主要项目文件夹(应用程序根文件夹)像往常一样,我们有。考虑本作 testApp_USA

My first AndroidManifest.xml is in main project folder (application root folder) as usual that we have. Consider this for testApp_USA.

我的第二个的Andr​​oidManifest.xml 是单独的包在主体工程。考虑本作 testApp_CANADA

My second AndroidManifest.xml is in separate package under main project. Consider this for testApp_CANADA.

两个的Andr​​oidManifest.xml 有相应的启动画面,定义图标不同的发射活动。包名称在两个给定的不同,使它们将创建不同的apk文件按要求。

Both AndroidManifest.xml have different launcher activities with corresponding splash screens, icons defined. The package names are given different in both so that they will create different .apk files as per requirement.

现在,如何切换 testApp_USA / testApp_CANADA之间code 提供我的主要的应用程序已经设置:

Now, how to switch code between testApp_USA/testApp_CANADA provided my main app has setting:

public static final String app_Name = "testApp_CANADA" ;

更清楚地

如何调用特定的Andr​​oidManifest.xml 根据值 APP_NAME

使用当前的设置,我有,只有第一个的Andr​​oidManifest.xml 总是被调用。

With the current setup that I have, only first AndroidManifest.xml is called always.

推荐答案

我有类似的问题,把项目以不同的市场 - 谷歌播放,三星,亚马逊。所有code的基础是一样的,区别只在计费code。

I had similar problem with putting project to different markets - Google Play, Samsung, Amazon. All code base is the same, difference only in billing code.

我发现最好的解决办法是建立每个市场单独的项目,推动共同code到库项目。

The best solution I found is creating separate project for each market and pushing common code into library project.

在更多的细节,你需要离开共同code的主体工程,使其成为库项目,并启用清单合并为图书馆和儿童项目。 添加以下行主项目的project.properties:

In more detail, you need to leave common code in main project, make it library project and enable manifest merger for library and child projects. Add following lines to project.properties of main project:

android.library=true
manifestmerger.enabled=true

和这对每一个子项目的project.properties:

and this to project.properties of every child project:

android.library.reference.1=../testApp //absolute or relative path to your main project
manifestmerger.enabled=true

此外,你需要的主要项目附加在ADT插件库(在Eclipse - 项目属性 - > Android的)所有的子项目。 主要项目清单不应包含任何发射活动,它会被忽略,同样的事情appWidget XML的配置和活动,如果你有一些。

Also you need to attach main project as library in ADT plugin (in Eclipse - project properties -> Android) to all child projects. Main project manifest should not contain any launcher activity, it will be ignored, same thing with appWidget xml's and config activities, if you have some.

在孩子的项目,您可以配置任何你想要的,并通过扩展或只使用需要的类为普通的Java库中使用的主要code。此外,您还可以使用主要的项目活动,服务,广播接收器等只是因为他们是你的孩子的项目没有子项目的舱单任何重复。 所有的配置之后,你可以建立需要的项目需要国家像往常一样一个项目,你会有不同的apk为不同国家,只要你想。

In child projects you can configure whatever you want and use main code by extending or just using needed classes as normal Java library. Also, you can use main project activities, services, broadcast receivers, etc just as they are in your child project without any duplication of manifest of child projects. After all configured, you can just build needed project for needed country as usual single project and you would have different apk's for different countries, as you want.

下面是明显的合并http://www.platoevolved.com/blog/programming/android/merging-android-manifest-files/

请注意,此功能中添加了ADT版本20 preVIEW 3。

Note, this feature was added in ADT version 20 preview 3.

希望这有助于。

 
精彩推荐
图片推荐