简体   繁体   English

Android产品风味清单

[英]Android Product Flavors Manifests

I'm working on my first android app, and I'm just getting started with product flavors. 我正在开发我的第一个android应用程序,而我刚开始使用产品口味。 I have a free version in beta, and I'm starting to make aa paid version. 我有一个免费的Beta版,现在开始制作一个付费版本。 I'm a bit confused about the manifests. 我对清单感到有些困惑。

The paid version will have one activity that the free version does not, and the two will have different permissions. 付费版本将具有一个活动,而免费版本将具有一个活动,而两者将具有不同的权限。 I'm thinking that I will remove the permissions from the main manifest, that the free manifest will have nothing in it but its permissions, and the paid manifest will have nothing in it but its permissions and the extra activity. 我正在考虑要从主清单中删除权限,免费清单中除了权限之外将什么都没有,付费清单除了其权限和额外的活动之外将什么都没有。

For example, the free manifest might be 例如,免费清单可能是

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app">

    <uses-permission android:name="android.permission.INTERNET"/>
    </uses-permission>

</manifest>

Is this correct? 这个对吗?

That's correct, however, I would recommend you put all common Manifest information in the main , as CommonsWare mentioned. 没错,但是,我建议您将所有常见的清单信息放在main ,如CommonsWare所述。

Also, as a tip, if you do need to replace a value in the main Manifest for any reason (debugging for example), I would use the tools:replace tag like so: 另外,作为提示,如果您出于任何原因(例如调试)确实需要替换main清单中的值,我将使用tools:replace标签,如下所示:

Free flavor: 自由风味:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      package="com.example">

    <application
        android:name=".FreeApp"
        android:allowBackup="false"
        tools:replace="allowBackup,name"/>

</manifest>

This would replace the tags name and allowBackup from main with what you have in this manifest. 这将更换标签nameallowBackupmain与你有这明显的是什么。

I recommend you check out the following link for more information about flavoring and variants, in case you haven't already: 我建议您查看以下链接,以获取有关调味剂和变体的更多信息,以防您尚未这样做:

https://developer.android.com/studio/build/build-variants.html https://developer.android.com/studio/build/build-variants.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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