Android Stuido 实现多渠道打包
source link: http://www.androidchina.net/4230.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
之前在这篇文章http://blog.csdn.net/zouchengxufei/article/details/46486629里涉及到根据不同的平台打包多个的问题,又在这篇文章http://blog.csdn.net/zouchengxufei/article/details/50176963里涉及到不同渠道的获取问题,所以想看看多渠道打包的问题!
由前两篇文章可以确定,多渠道打包的思路,使用productFlavors和meta-data,现在的关键问题是gradle脚本怎么给AndroidManifest.xml赋值?
找了半天,找到一个好的地方:http://blog.saymagic.cn/2015/04/18/build-gradle.html?utm_source=tuicool&utm_medium=referral,感谢这位作者!使用manifestPlaceholders这个属性
文件配置AndroidManifest.xml:
<application ..>
<meta-data android:name="UMENG_CHANNEL" android:value="${app}" />
<application>
build.gradle文件配置:
apply plugin: 'com.android.application'
Properties properties=new Properties();
properties.load(project.rootProject.file("local.properties").newDataInputStream())
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.liubo.testapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
manifestPlaceholders = [app: properties.getProperty("xiaomi")]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
xiaomi {
manifestPlaceholders = [app: properties.getProperty("xiaomi")]
}
baidu {
manifestPlaceholders = [app: properties.getProperty("baidu")]
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}
local.properties文件:
sdk.dir=D\:\\Java\\Android_SDK
xiaomi=xiaomikey
baidu=baidukey
以上文件配置,就只做了小米和百度升级的key,实现多渠道打包
转载请注明:Android开发中文站 » Android Stuido 实现多渠道打包
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK