ReactNative 多渠道打包

多渠道打包

  1. 友盟官网注册开发者账号,创建应用拿到AppKey;
  2. AndroidManifest.xml 添加权限,配置友盟;
<meta-data android:name="UMENG_APPKEY" android:value="${UMENG_APPKEY}" />
<!-- 渠道打包必须打开注释 -->
<!--<meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}" />-->
  1. 引入友盟依赖;
  2. 4.android - app -build.gradle
…
/* 友盟多渠道打包 */
productFlavors {
yingyongbao {} // 腾讯应用宝
vivo {} // vivo
oppo {} // Oppo-可可软件商店

productFlavors.all { flavor ->
flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
 }
}

applicationVariants.all { variant ->
variant.outputs.each { output ->
	// For each separate APK per architecture, set a unique version code as described here:
	// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
	def versionCodes = ["armeabi-v7a":1, "x86":2]
	def abi = output.getFilter(OutputFile.ABI)
	if (abi != null) {  // null for the universal-debug, universal-release variants
		output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
	}
	//Android 修改打包文件名
		variant.outputs.all {
		outputFileName = "${variant.name}-${releaseTime()}-${variant.versionName}(${variant.versionCode}).apk"
		}
	}
}