当前位置:   article > 正文

android 多渠道打包,build.gradle文件配置、manifest文件配置_manifest build.gradle

manifest build.gradle

build.gradle

apply plugin: 'com.android.application'

android {
    signingConfigs {
        SP {
            keyAlias 'ywyysq'
            keyPassword '123456'
            storeFile file('/Users/apple/AndroidStudioProjects/APPKEY/ywyysq.jks')
            storePassword '123456'
        }
    }
    compileSdkVersion 22
    buildToolsVersion '23.0.2'
    defaultConfig {
        applicationId "com.jshy.yyyysq"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 2
        versionName "2.0"
        multiDexEnabled true //dex突破65535限制
    }
    buildTypes {

        all {
            buildConfigField "String", "GIT_REVISION", "\"${getGitRevision()}\""
            manifestPlaceholders = [UMENG_APPKEY: "56e6164e67e58e9a23000439",]
        }

        debug {
            applicationIdSuffix ".debug"
            versionNameSuffix "-Debug"
            resValue "string", "app_name", "调试1.0"
        }

        release {
            minifyEnabled true //译:使变小enabled。   即启用混淆器
            shrinkResources true
            zipAlignEnabled false //设置为false 为了不产生unaligned的apk  //混淆后的zip优化,默认为true,可不写。当不显示配置为true时,不会生成unaligned.apk
            signingConfig signingConfigs.SP
            resValue "string", "app_name", "AU影院"
            /*if (project.hasProperty("keyPath") && project.hasProperty("keyPass") && project.hasProperty("keyAlias")) {
                signingConfigs.release.storeFile file(keyPath)
                signingConfigs.release.keyAlias = keyAlias
                signingConfigs.release.storePassword = keyPass
                signingConfigs.release.keyPassword = keyPass
            }*/
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            applicationVariants.all { variant ->
                variant.outputs.each { output ->
                    def outputFile = output.outputFile
                    if (outputFile != null && outputFile.name.endsWith('.apk')) {
                        def fileName = "${variant.productFlavors[0].name}_${getDate()}_${getGitRevision()}.apk"
                        output.outputFile = new File(outputFile.parent, fileName)
                    }
                }
            }
        }
    }

    // 多渠道打包
    productFlavors {

        jshy_video {
            manifestPlaceholders = [
                    JSPAY_APP_KEY: "ekiw8kkjq38vqgc",
                    //LINE_ENSURE: "***************"
                    CHANNEL_KEY  : "59f99ab6901e151edadf8792a643f7a3",
                    //LINE_ENSURE: "********************************"
                    UMENG_VALUE  : "sp0100"
                    //LINE_ENSURE: "******"
            ]
        }

        xinlianAZ01 {
            manifestPlaceholders = [
                    JSPAY_APP_KEY: "ekiw8kkjq38vqgc",
                    //LINE_ENSURE: "***************"
                    CHANNEL_KEY  : "59f99ab6901e151edadf8792a643f7a3",
                    //LINE_ENSURE: "********************************"
                    UMENG_VALUE  : "sp0422"
                    //LINE_ENSURE: "******"
            ]
        }

        lianmeng69 {
            manifestPlaceholders = [
                    JSPAY_APP_KEY: "o0wiv04i20g8mwf",
                    //LINE_ENSURE: "***************"
                    CHANNEL_KEY  : "c956d0e9766579062c5c63dd9525d2d0",
                    //LINE_ENSURE: "********************************"
                    UMENG_VALUE  : "sp0301"
                    //LINE_ENSURE: "******"
            ]
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

def getDate() {
    def date = new Date()
    def formattedDate = date.format('yyyyMMdd-HHmmss')
    return formattedDate
}

def getGitRevision() {
    return "git rev-parse --short HEAD".execute().text.trim()
}

def replace(filePath, oldStr, newStr) {
    def f = file(filePath)
    String content = f.getText()
    content = content.replaceAll(oldStr, newStr)
    f.write(content)
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile files('libs/jsoup-1.8.1.jar')
    compile files('libs/TencentLocationSDK_v4.0_r139747.jar')
    compile files('libs/JshyPay_zw_asset_14.1.jar')
    compile files('libs/mmlog.jar')
    compile files('libs/universal-image-loader-1.9.5.jar')
    compile files('libs/pay_plugin.jar')
}

AndroidManifest.xml

<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.jshy.yyyysq"
          android:versionCode="1"
          android:versionName="1.0">

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18"/>
    <!--所有需要权限-->
    <!--application-->
    <application
        android:name=".activity.MyApplication"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/MyAppTheme">
        <!--====================KEY=========================-->
        <!--渠道号-->
        <meta-data
            android:name="JSPAY_APP_KEY"
            android:value="${JSPAY_APP_KEY}"/>

        <!--渠道号对应码-->
        <meta-data
            android:name="CHANNEL_KEY"
            android:value="${CHANNEL_KEY}"/>

        <!--友盟渠道对应值-->
        <meta-data
            android:name="UMENG_VALUE"
            android:value="${UMENG_VALUE}"/>

        <!--友盟渠道key-->
        <meta-data
            android:name="UMENG_APPKEY"
            android:value="56e6164e67e58e9a23000439"/>
        <!--====================KEY=========================-->

    </application>

</manifest>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/265455
推荐阅读
相关标签
  

闽ICP备14008679号