build.app:
productFlavors { // app_one { // applicationId "com.example.app1" // manifestPlaceholders = [ // app_name:"测试-1" // ] // } // app_two { // applicationId "com.example.app2" // manifestPlaceholders = [ // app_name:"测试-2" // ] // } // app_three { // applicationId "com.example.app3" // manifestPlaceholders = [ // app_name:"测试-3" // ] // } app_four { applicationId "com.xxx.xxx" manifestPlaceholders = [ app_name : "appName", app_icon : "@mipmap/icon", JPUSH_PKGNAME: applicationId, JPUSH_APPKEY : "xxxxxx", //JPush上注册的包名对应的appkey. JPUSH_CHANNEL: "自定义渠道名称", //用户渠道统计的渠道名称 company_name : "xxx" ] } }
这是每一个appid 代表一个需要打包的apk jpush等第三方sdk的参数也可以写在这里
MyApplication:
switch (getApplicationContext().getPackageName()) { case "com.xxx.xxx": Log.e("" + getApplicationContext().getPackageName().toString()); Url = "http://xxx"; break; default: break; }
可以在Application中判断每一个apk需要用的url 或者其他一些初始化参数
manifest:
<application android:name=".MyApplication" android:allowBackup="true" android:icon="${app_icon}" android:label="${app_name}" android:roundIcon="${app_icon}" android:supportsRtl="true" android:theme="@style/AppTheme" tools:replace="android:label">可以在manifest中 调用build.app 中的 app_icon 和app_name