Android 集成Bugly应用升级,热更新(最详细)

使用Bugly的东西,首先要创建一个产品,获取到一个APP ID;
Bugly官网

现在开始集成

在根部的build.gradle中添加
dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'//因为使用3.4版本的会编译错误,说有的方法没有了,所以我查询资料后,改为3.2的
        classpath "com.tencent.bugly:tinker-support:1.1.5"//这一行
    }

在Module中添加依赖

    implementation "com.android.support:multidex:1.0.2" // 多dex配置
    //注释掉原有bugly的仓库
    //compile 'com.tencent.bugly:crashreport:latest.release'//其中latest.release指代最新版本号,也可以指定明确的版本号,例如1.3.4
    implementation 'com.tencent.bugly:crashreport_upgrade:1.3.6'
    // 指定tinker依赖版本(注:应用升级1.3.5版本起,不再内置tinker)
    implementation 'com.tencent.tinker:tinker-android-lib:1.9.9'
    //implementation 'com.tencent.bugly:nativecrashreport:latest.release'
    implementation 'com.android.support:support-v4:28.0.0'
    //其中latest.release指代最新版本号,也可以指定明确的版本号,例如2.2.0
    
 defaultConfig {//这里面添加这个
        multiDexEnabled true
    }

需要配置keystore文件

signingConfigs {
        release {
            keyAlias '自己的'
            keyPassword '自己的'
            storeFile file('自己的')
            storePassword '自己的'
        }
    }

buildTypes {
        release {
            signingConfig signingConfigs.release//添加这个
        }
    }

在这里插入图片描述

然后在最上面添加

apply from: 'tinker-support.gradle'

在你的module目录下添加tinker-support.gradle文件,与build.gradle文件同级

里面添加

apply plugin: 'com.tencent.bugly.tinker-support'

def bakPath = file("${buildDir}/bakApk/")//打基准包的路径

/**
 * 此处填写每次构建生成的基准包目录
 */
def baseApkDir = "app-0619-16-52-37"//打补丁包的时候,需要将名称换成基准包的名称,保持一致

/**
 * 对于插件各参数的详细解析请参考
 */
tinkerSupport {
// tinkerEnable功能开关
    tinkerEnable = true
    // 开启tinker-support插件,默认值true
    enable = true

    // 指定归档目录,默认值当前module的子目录tinker
    autoBackupApkDir = "${bakPath}"

    // 是否启用覆盖tinkerPatch配置功能,默认值false
    // 开启后tinkerPatch配置不生效,即无需添加tinkerPatch
    overrideTinkerPatchConfiguration = true

    // 编译补丁包时,必需指定基线版本的apk,默认值为空
    // 如果为空,则表示不是进行补丁包的编译
    // @{link tinkerPatch.oldApk }
    baseApk = "${bakPath}/${baseApkDir}/app-release.apk"

    // 对应tinker插件applyMapping
    baseApkProguardMapping = "${bakPath}/${baseApkDir}/app-release-mapping.txt"

    // 对应tinker插件applyResourceMapping
    baseApkResourceMapping = "${bakPath}/${baseApkDir}/app-release-R.txt"

    // 构建基准包和补丁包都要指定不同的tinkerId,并且必须保证唯一性
    tinkerId = "patch-1.0.3"//例:基准包:"base-1.0.0"  补丁包:"patch-1.0.0"

    // 构建多渠道补丁时使用
    // buildAllFlavorsDir = "${bakPath}/${baseApkDir}"

    // 是否启用加固模式,默认为false.(tinker-spport 1.0.7起支持)
    // isProtectedApp = true

    // 是否开启反射Application模式
    enableProxyApplication = true//这个是确认使用自己的application还是bugly封装的的;若是为true则是用自己的,为false则是用bugly封装的

    // 是否支持新增非export的Activity(注意:设置为true才能修改AndroidManifest文件)
    supportHotplugComponent = true

}

/**
 * 一般来说,我们无需对下面的参数做任何的修改
 * 对于各参数的详细介绍请参考:
 * https://github.com/Tencent/tinker/wik
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值