[英]re-use the androidmanifest.xml in library project in android studio
I am buiding an android application with two version one for free and the other for paid. 我正在建立一个具有两个版本的android应用程序,一个是免费的,另一个是付费的。
Since most of the UI,feature of the two version are the same, so I create a Android library project to hold the common components of the app including the common Activity
, View
, Layout
, Resources
and the AndroidManifest.xml
. 由于两个版本的大多数UI的功能都相同,因此我创建了一个Android库项目来容纳应用程序的公共组件,包括公共
Activity
, View
, Layout
, Resources
和AndroidManifest.xml
。
The library project is named MapBase
. 该库项目名为
MapBase
。
Then I create two moudles(android application) named MapForFree
and MapForPaid
. 然后创建两个名为
MapForFree
和MapForPaid
(Android应用程序)。
The structure: 结构:
+MapProject
+MapBase
build.gradle
+MapForFree
build.gradle
+MapForPaid
build.gradle
build.gradle(with empty content)
settings.gradle(content==> include ':MapBase', ':MapForFree', ':MapForPaid')
The MapBase/build.gradle: MapBase / build.gradle:
apply plugin: 'android-library'
.....
dependencies {
compile 'com.android.support:appcompat-v7:18.0.0'
compile 'com.android.support:support-v4:18.0.0'
compile fileTree(dir: 'libs', include: '*.jar')
}
MapForFee/build.gradle: MapForFee / build.gradle:
...
apply plugin: 'android'
...
Now I want to the MapForFree
and MapForPaid
to refer to the MapBase
module, but I meet two problems: 现在,我想让
MapForFree
和MapForPaid
引用MapBase
模块,但是遇到两个问题:
1 The refer manner. 1引用方式。
Should I set the dependency in the build.gradle file or using android stuido itself? 我应该在build.gradle文件中设置依赖项还是使用android stuido本身?
2 The AndroidManifest.xml. 2 AndroidManifest.xml。
Since the MapForFree
and MapForPaid
module have the same AndroidManifest.xml, so I copy this file from MapBase
. 由于
MapForFree
和MapForPaid
模块具有相同的AndroidManifest.xml,因此我从MapBase
复制了此文件。
However, the file declare some Activities defined in the MapBase
module. 但是,该文件声明了一些在
MapBase
模块中定义的MapBase
。 How to resolve this? 如何解决呢?
I'm not sure about your first question. 我不确定你的第一个问题。 For your second question,
MapForFree
and MapForPaid
should each have their own AndroidManifest.xml
. 对于第二个问题,
MapForFree
和MapForPaid
应该分别具有自己的AndroidManifest.xml
。 Any components that need to be defined in the manifest that come from MapBase
should be defined using the full package name of MapBase
before the component name. 必须在来自
MapBase
的清单中定义的所有组件MapBase
在组件名称之前使用MapBase
的完整程序包名称进行定义。
For example, if you have an Activity
defined in MapBase
called MapBaseActivity
, and it is in package com.example.app
, it should be listed in the manifests for both MapForFree
and MapForPaid
as: 例如,如果您在
MapBase
定义了MapBase
名为MapBaseActivity
的Activity
,并且它在com.example.app
包中,则应在清单中同时将其列出为MapForFree
和MapForPaid
:
<activity android:name="com.example.app.MapBaseActivity">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.