zoukankan      html  css  js  c++  java
  • android gradle 多渠道打包

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.7.+'
        }
    }
    apply plugin: 'android'
     
    repositories {
        mavenCentral()
    }
     
    dependencies {
        compile fileTree(dir: 'libs', include: '*.jar')
    }
     
    android {
        compileSdkVersion 19
        buildToolsVersion '19.0.0'
     
        defaultConfig {
            minSdkVersion 9
            targetSdkVersion 19
        }
     
        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['src']
                resources.srcDirs = ['src']
                aidl.srcDirs = ['src']
                renderscript.srcDirs = ['src']
                res.srcDirs = ['res']
                assets.srcDirs = ['assets']
            }
     
            threesixo.setRoot('build-types/360')
            anzhi.setRoot('build-types/AnzhiMarket')
            baidu.setRoot('build-types/Baidu')
            hiapk.setRoot('build-types/HiApk')
            jifeng.setRoot('build-types/JiFeng')
            playstore.setRoot('build-types/PlayStore')
            tencent.setRoot('build-types/Tencent')
            wandoujia.setRoot('build-types/WanDouJia')
            xiaomi.setRoot('build-types/XiaoMi')
     
            // Move the tests to tests/java, tests/res, etc...
            instrumentTest.setRoot('tests')
     
            // Move the build types to build-types/<type>
            // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
            // This moves them out of them default location under src/<type>/... which would
            // conflict with src/ being used by the main source set.
            // Adding new build types or product flavors should be accompanied
            // by a similar customization.
            debug.setRoot('build-types/debug')
            release.setRoot('build-types/release')
        }
     
        signingConfigs {
            MyConfig{
                storeFile file("E:\my.keystore")
                storePassword "******"
                keyAlias "myapp"
                keyPassword "******"
            }
        }
     
        buildTypes{
            release {
                signingConfig  signingConfigs.MyConfig
            }
        }
     
        productFlavors {
            threesixo {}
            anzhi {}
            baidu {}
            hiapk {}
            jifeng{}
            playstore {}
            tencent{}
            wandoujia{}
            xiaomi{}
        }
    }

    比如:build-types360AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.mypackage">
     
        <application >
            <meta-data android:name="UMENG_CHANNEL" android:value="GooglePlay" />
        </application>
    </manifest>

    通过gradle构建体系中的Flavors来配置友盟的渠道.
    在src的同级目录下建立build-types目录,再建立各个渠道的目录,将配置了不同的标签的AndroidManifest.xml文件放置到相应的渠道目录下.
    执行gradle assembleRelease 在build/apk目录下生成签名的不同的渠道的apk文件

  • 相关阅读:
    haproxy报错解决
    haproxy安装
    gitlab配置webhook报错解决
    git_push报错
    DNS配置
    centos7 选定默认启动内核,及删除无用内核
    ansible安装、配置ssh、hosts、测试连接
    公司手机打卡app时间和百度时间差30秒解决
    所有编辑语言的共性内容元素
    php使用正则函数使用详解
  • 原文地址:https://www.cnblogs.com/xiaorenwu702/p/4002051.html
Copyright © 2011-2022 走看看