Android进阶之路 - AndroidStudio内自带的精简多渠道打包方式
2017-08-11 10:30
901 查看
第一步:
AndroidMainfest(清单文件)中的application内添加:
如:
第二步:
build(app)中,android内添加渠道名,这里要注意的是 如果是数字开头是不行的!需要添加下划线!这是俩种方式,可以使用uc的方式添加渠道,也可以使用现在的不直接声明的模式。个人介意第一种样式!
其实就是一个遍历器:
如:
第三步:
在此时,我们的配置已经做完,可以打包,但需注意你既然要打渠道包,必然是要上appStore的,这里就涉及到了一个签名的问题,你可以通过http://blog.csdn.net/qq_20451879/article/details/73251070进行学习,不然你打出的也是没有签名的包,用户是无法安装的!
AndroidStudio内的Gradle打包:
![](https://oscdn.geek-share.com/Uploads/Images/Content/201708/efa25d23ffbbed0621481f3a04569bbc)
最终结果:
(没签名的包状态)
![](https://oscdn.geek-share.com/Uploads/Images/Content/201708/7677c085c03f19f8a99e9d463950a857)
(签名的包状态)
AndroidMainfest(清单文件)中的application内添加:
<meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}" />
如:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.dow.loadingview"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/Theme.AppCompat.Light.NoActionBar"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}" /> </application> </manifest>
第二步:
build(app)中,android内添加渠道名,这里要注意的是 如果是数字开头是不行的!需要添加下划线!这是俩种方式,可以使用uc的方式添加渠道,也可以使用现在的不直接声明的模式。个人介意第一种样式!
productFlavors{ uc { manifestPlaceholders = [UMENG_CHANNEL_VALUE: "uc"] } _360 { manifestPlaceholders = [UMENG_CHANNEL_VALUE: "360"] } baidu{ manifestPlaceholders = [UMENG_CHANNEL_VALUE: "baidu"] } default_channel{} wandoujia{} yingyongbao{} xiaomi{} huawei{} jifeng{} }
其实就是一个遍历器:
productFlavors.all { flavor -> flavor.manifestPlaceholders = [ UMENG_CHANNEL_VALUE:name ] }
如:
apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion '23.0.3' defaultConfig { applicationId "com.example.dow.loadingview" minSdkVersion 16 targetSdkVersion 23 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" manifestPlaceholders = [ UMENG_CHANNEL_VALUE:"default_channel" ] } buildTypes { debug { minifyEnabled false debuggable true } release { minifyEnabled true // proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' // signingConfig signingConfigs.config debuggable false } } productFlavors{ uc { manifestPlaceholders = [UMENG_CHANNEL_VALUE: "uc"] } _360 { manifestPlaceholders = [UMENG_CHANNEL_VALUE: "360"] } baidu{ manifestPlaceholders = [UMENG_CHANNEL_VALUE: "baidu"] } default_channel{} wandoujia{} yingyongbao{} xiaomi{} huawei{} jifeng{} } productFlavors.all { flavor -> flavor.manifestPlaceholders = [ UMENG_CHANNEL_VALUE:name ] } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:24.2.1' }
第三步:
在此时,我们的配置已经做完,可以打包,但需注意你既然要打渠道包,必然是要上appStore的,这里就涉及到了一个签名的问题,你可以通过http://blog.csdn.net/qq_20451879/article/details/73251070进行学习,不然你打出的也是没有签名的包,用户是无法安装的!
AndroidStudio内的Gradle打包:
最终结果:
(没签名的包状态)
(签名的包状态)
相关文章推荐
- Android Studio多渠道打包方式一:通过外部文件来写渠道信息
- Android Studio使用Gradle多渠道自动打包
- Android Studio使用教程(六):Gradle多渠道打包
- 【Android 进阶】友盟的多渠道打包方式
- 【Android 进阶】美团的多渠道打包方式
- 手把手教你AndroidStudio多渠道打包
- Android多渠道打包汇总(六)—— 美团的多渠道打包方式
- AndroidStudio多渠道打包的方案
- Android Studio多渠道打包
- android studio多渠道多包名多apk打包
- 手把手教你AndroidStudio多渠道打包
- AndroidStudio多渠道打包
- Android Studio签名打包的两种方式
- Android Studio多渠道打包和代码混淆教程
- Android Studio签名打包的两种方式
- android studio多渠道打包
- 手把手教你AndroidStudio多渠道打包
- Android高阶之Android studio友盟多渠道打包方式
- 用Android studio多渠道打包以及使用不同资源(包括icon或者其他图片等) 方法二
- Android美团多渠道打包方式