简体   繁体   English

配置build.gradle以使用不同的应用程序ID构建应用程序

[英]Configure build.gradle for building apps with different application id

I need to generate different apks from the same code. 我需要从同一代码生成不同的apk。 The only difference would be the applicationId defined in build.gradle. 唯一的区别是build.gradle中定义的applicationId。 I have defined some permissions in AndroidManifest. 我在AndroidManifest中定义了一些权限。 These permissions start with the application id. 这些权限以应用程序ID开头。 eg 例如

APK1 build.gradle applicationId 'com.example.app1' APK1 build.gradle applicationId'com.example.app1'

Android Manifest Android清单

uses-permission android:name="com.example.app1.permission.PERMISSION_NAME" 使用权限android:name =“ com.example.app1.permission.PERMISSION_NAME”

APK2 build.gradle applicationId 'com.example.app2' APK2 build.gradle applicationId'com.example.app2'

Android Manifest Android清单

uses-permission android:name="com.example.app2.permission.PERMISSION_NAME" 使用权限android:name =“ com.example.app2.permission.PERMISSION_NAME”

I need to know an efficient way to achieve this. 我需要知道一种有效的方法来实现这一目标。 If possible, I would like to avoid creating two different AndroidManifest files depending on the flavour. 如果可能,我希望避免根据口味创建两个不同的AndroidManifest文件。 Please suggest. 请提出建议。

You can use the ${applicationId} placeholder. 您可以使用${applicationId}占位符。
Something like: 就像是:

<uses-permission android:name="${applicationId}.permission.PERMISSION_NAME" />

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

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