Android多渠道打包
来源:互联网 发布:手机动漫壁纸软件 编辑:程序博客网 时间:2024/06/03 18:16
1:添加对友盟库的依赖
//添加友盟统计库依赖compile 'com.umeng.analytics:analytics:latest.integration'
添加完依赖后sync now下
2:就是在Mainfest.xml中去声明我们的appkey,以及我们的渠道占位符
2.1 相应的权限
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><uses-permission android:name="android.permission.INTERNET"/><uses-permission android:name="android.permission.READ_PHONE_STATE"/>
2.2 添加友盟相关meta-data
<meta-data android:value="5982cf41734be43474000d24" android:name="UMENG_APPKEY"/><!--友盟 APPKey key可以替换成自己的--> <meta-data android:value="${UMENG_CHANNEL_VALUE}" android:name="UMENG_CHANNEL"/><!--渠道号 加$是为了动态修改渠道包-->
3:在我们的应用的build.gradle中去动态的替换掉我们占位符的value即可
apply plugin: 'com.android.application'android { compileSdkVersion 26 buildToolsVersion "25.0.3" defaultConfig { applicationId "nuro.nuro.imook60" minSdkVersion 15 targetSdkVersion 26 versionCode 1 versionName "1.0" multiDexEnable true //突破应用方法数65535的一个限制 manifestPlaceholders = [UMENG_CHANNEL_VALUE:"umeng"] } //添加我们的签名文件配置,必须先定义 signingConfigs{ debug{} //为我们的release包添加签名文件配置,如果之前有在build中设置, // 这个里面的参数必须和build相同,否则会出现错误 release{ storeFile file("E:/Android demo/imook6.0/imook6.0.jks") storePassword "123456" keyAlias "imook" keyPassword "123456" } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release//为我们的apk指定要使用的签名文件 //指定我们release包的输出文件名就是我们的渠道名字 applicationVariants.all{ variant -> variant.outputs.each{ output -> def outFile = output.outputFile if (outFile != null && outFile.name.endsWith(".apk")){ def fileName = "${variant.productFlavors[0].name}"+".apk" output.outputFile = new File(outFile.parent,fileName); } } } } } productFlavors{ xiaomi{ // mainfestPlaceholders = [UMENG_CHANNEL_VALUE:"xiaomi"] // resValue "string","app_name","xiaomi_app"//替换Value } wandoujia{ // mainfestPlaceholders = [UMENG_CHANNEL_VALUE:"wandoujia"] // resValue "string","app_name","wandoujia_app" } } //脚本动态完成多渠道打包 productFlavors.all{ flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE:name] }}dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:26.0.0-alpha1' compile 'com.android.support:design:26.0.0-alpha1' //添加友盟统计库依赖 compile 'com.umeng.analytics:analytics:latest.integration'}
4:window下在控制台使用我们的gradlew assembleRelease自动的打出所有渠道的包
以下是Android多渠道打包demo下载地址:http://download.csdn.net/detail/qq_27922603/9920488
不懂的地方可以联系qq:1143403680
阅读全文
0 0
- Android多渠道打包(一):基础多渠道打包
- Android多渠道打包(四):360多渠道打包
- Android多渠道打包(五):360多渠道打包+
- android 多渠道自动打包
- android apk多渠道打包
- Android多渠道打包APK
- android 多渠道打包
- Android 多渠道自动打包
- android应用多渠道打包
- Android Ant 多渠道打包
- Android多渠道Ant打包
- android多渠道打包
- Android多渠道打包工具
- android ant 多渠道打包
- Android studio 多渠道打包
- Android Studio多渠道打包
- Android studio 多渠道打包
- android Gradle多渠道打包
- 循环的试题一
- 16CF2--1002--(dfs)
- Eclipse 下找不到或无法加载主类的解决办法
- MySQL定期分析检查与优化表
- 数据库总结(二)
- Android多渠道打包
- JVM内存管理和GC机制
- 畅通工程再续||HDU1875
- Python在操作系统层面上的操作
- MFC和Qt分别使用Qt生成的Dll。
- HDU1405 The Last Practice
- linux中硬链接与软链接的区别与联系
- iOS开发中系统的UITableViewCell只有当有数据的时候显示分割线
- 外网ip注册dubbo服务