美团多渠道打包

1.修改项目根目录下build.gradle文件
在buildscript下的dependencies中增加:

classpath 'com.meituan.android.walle:plugin:1.1.6'

2. 修改app工程的build.gradle文件,增加如下信息:

  • 1)头部增加:
apply plugin: 'walle'
  • 2)确保有签名配置,下面是样例,
signingConfigs {
        release {
            storeFile file("../xx.jks")        // 打包的文件的地址
            storePassword "123456"
            keyAlias "xx"
            keyPassword "123456"
        }
        debug {
            storeFile file("../xx.jks")
            storePassword "123456"
            keyAlias "xx"
            keyPassword "123456"
        }
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.debug
        }
    }
  • 3)增加如下配置:
walle {
    // 指定渠道包的输出路径
    apkOutputFolder = new File("${project.buildDir}/outputs/channels");
    // 定制渠道包的APK的文件名称
    apkFileNameFormat = '${appName}-${packageName}-${channel}-${buildType}-v${versionName}-${versionCode}-${buildTime}.apk';
    // 渠道配置文件
    channelFile = new File("${project.getProjectDir()}/channel")
}
  • 4)app的在dependencies中增加:
implementation 'com.meituan.android.walle:library:1.1.6'

3. 在app工程下新建文件channel,放置渠道信息(根据实际需要修改):

xiaomi
360
huawei
vivo

4. 获取渠道样例:

String channel = WalleChannelReader.getChannel(this.getApplicationContext());

5. 对于要设置到友盟里去,则需要参考友盟的设置方法。
6. 打包命令(更多命令及用法参考附录官方指导):

 mac:./gradlew clean assembleReleaseChannels
 windows:gradlew clean assembleReleaseChannels

7. build.gradle 总的配置文件,供参考:

apply plugin: 'com.android.application'

apply plugin: 'walle'

android {
compileSdkVersion 28

defaultConfig {
    applicationId "com.example.administrator.dabao"
    minSdkVersion 19
    targetSdkVersion 28
    versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }


    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            signingConfig signingConfigs.create("release")
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    signingConfigs {
        release {
            v2SigningEnabled true
            storeFile file("F:\\Android_studio\\keystore\\android.keystore")
            storePassword "123456"
            keyAlias "key0"
            keyPassword "123456"
        }
    }



}

walle {
    // 指定渠道包的输出路径
    apkOutputFolder = new File("${project.buildDir}/outputs/channels");
    // 定制渠道包的APK的文件名称
    apkFileNameFormat = '${appName}-${packageName}-${channel}-${buildType}-v${versionName}-${versionCode}-${buildTime}.apk';
    // 渠道配置文件
    channelFile = new File("${project.getProjectDir()}/channel")
}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.3'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'

    implementation 'com.meituan.android.walle:library:1.1.6'

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值