标签:name data override each ann info ant 修改 cep
【友盟打包】
第1步:
public class MApplication extends Application{
private static String channel;
@Override
public void onCreate() {
super.onCreate();
channel=initChannel();
}
/**
* 初始化渠道信息
*/
private String initChannel() {
try {
PackageManager pm = getPackageManager();
ApplicationInfo info = pm.getApplicationInfo(getPackageName(),
PackageManager.GET_META_DATA);
return info.metaData.getString("UMENG_CHANNEL");
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return "";
}
}
第2步:
<application
<meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}"/>;
</application>
第3步:build.gradle
android {
/*------------------------------------------------------------------------------*/
productFlavors {
wandoujia {
//manifestPlaceholders = [UMENG_CHANNEL_VALUE: "wandoujia"]
applicationId "cn.andoop.apkpacktest"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
xiaomi {
//manifestPlaceholders=[UMENG_CHANNEL_VALUE: "xiaomi"]
}
}
productFlavors.all { flavor ->
flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith(‘.apk‘)) {
def fileName = outputFile.name.replace(".apk", "-${defaultConfig.versionName}.apk")
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
/*------------------------------------------------------------------------------*/
}
第4步:build——>generate......
效率高的打包方法可以用美团多渠道打包和360多渠道打包,但是渠道信息也是很容易修改,虽然可以加密,只是提高了修改的门槛
标签:name data override each ann info ant 修改 cep
原文地址:http://www.cnblogs.com/libuyi/p/6028907.html