怎样通过gradle进行多渠道打包
1:先到友盟注册个账号,选择“产品” --> “U App 应用统计”,添加一个app申请一个key,然后在Gradle中添加对友盟库的依赖:
compile 'com.umeng.analytics:analytics:latest.integration'
}
2:在Mainfest.xml中声明appkey,以及渠道占位符
3:在app的gradle中编写如下代码:
整个build.geadle截图:
signingConfigs代码块一定要写在buildTypes前面,否则会报下面这种错:
Could not find property 'releaseConfig' on SigningConfig container.
4:在Terminal 输入命令进行打包
windows电脑:gradlew assembleRelease
mac电脑:./gradlew assembleRelease
生成的apk在app/build/outputs/apk/ 目录下
视频学习:慕课网,Android Apk多渠道打包
根据功能点打不同包,可同时安装,在productFlavors中添加:
okHttp {
applicationIdSuffix "okhttp"
resValue "string", "app_name", "okhttp"
}
jpush {
applicationIdSuffix "jpush"
resValue "string", "app_name", "jpush"
}
这样两个包的applicationId分别是:com.xxx.xxx.okhttp ,com.xxx.xxx.jpush ,包名不变,手机上可同时安装