《一》首先在清单文单中添加动态渠道变量
<!--友盟--> <meta-data android:value="5f2bf8c3b4b08b653e91eec0(你自己的APPKey)" android:name="UMENG_APPKEY"/> <meta-data android:value="${UMENG_CHANNEL_VALUE}" android:name="UMENG_CHANNEL"/>可能权限
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name=" android.permission.ACCESS_NETWORK_STATE" /><二>在build.gradle设置productFlavors android下添加
productFlavors { kuan { manifestPlaceholders = [UMENG_CHANNEL_VALUE: "kuan"] } xiaomi { manifestPlaceholders = [UMENG_CHANNEL_VALUE: "xiaomi"] } qh360 { manifestPlaceholders = [UMENG_CHANNEL_VALUE: "qh360"] } baidu { manifestPlaceholders = [UMENG_CHANNEL_VALUE: "baidu"] } wandoujia { manifestPlaceholders = [UMENG_CHANNEL_VALUE: "wandoujia"] } }或者批量修改
android { productFlavors { kuan {} xiaomi {} qh360 {} baidu {} wandoujia {} } productFlavors.all { flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name] } }解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com
defaultConfig { applicationId "com.example.liangxq.shopping" minSdkVersion 24 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" flavorDimensions "versionCode" }《三》如果出现Android Generate Signed APK: Errors while building APK. You can find the errors 错误 解决办法 在build.gradle文件添加 想都不要想直接添加
lintOptions { checkReleaseBuilds false abortOnError false }不行的话在家这两行
aaptOptions.cruncherEnabled = false; aaptOptions.useNewCruncher = false还是不行的话一起加到android中
配置差不多就完了,接下来就是一顿操作
打包成功后显示