Tencent / tinker

Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.
Other
17.1k stars 3.33k forks source link

设置autoGenerateTinkerId = true 打包时,TINKER_ID 和 BUGLY_CHANNEL无法正常合并进apk中 #1629

Open seapeak233 opened 2 years ago

seapeak233 commented 2 years ago

异常类型:打包 autoGenerateTinkerId 设置为true 在一台机器上就正常打包,在另外一台机器上打包的APK就没有TINKER_ID在manifest内,在第三台机器上会概率性发生这个问题,目前没有发现哪儿出了问题,还是说

tinker版本: implementation 'com.tencent.bugly:crashreport_upgrade:1.5.23' implementation 'com.tencent.tinker:tinker-android-lib:1.9.14.18'

classpath "com.tencent.bugly:tinker-support:1.2.3"

gradle版本:6.9

是否使用热更新SDK: Bugly SDK

系统:Mac

配置:

//基准包路径
def baseApkPath = ""
//基准包mapping文件
def baseMappingPath = ""
//基准包R文件
def baseRPath = ""

apply plugin: 'com.tencent.bugly.tinker-support'
//打包运行的备份地址,会被build clean所清理,及时将备份文件取出另存为
def bakPath = file("${buildDir}/_bakApk/")
/**
 * 对于插件各参数的详细解析请参考
 */
tinkerSupport {

    // 开启tinker-support插件,默认值true
    enable = true

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

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

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

    // 对应tinker插件applyMapping
    baseApkProguardMapping = baseMappingPath

    // 对应tinker插件applyResourceMapping
    baseApkResourceMapping = baseRPath

    // 构建基准包和补丁包都要指定不同的tinkerId,并且必须保证唯一性
//    tinkerId = tinkerCheckId
    autoGenerateTinkerId = true

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

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

    // 是否开启反射Application模式
    enableProxyApplication = false

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

/**
 * 一般来说,我们无需对下面的参数做任何的修改
 * 对于各参数的详细介绍请参考:
 * https://github.com/Tencent/tinker/wiki/Tinker-%E6%8E%A5%E5%85%A5%E6%8C%87%E5%8D%97
 */
tinkerPatch {
    //oldApk ="${bakPath}/${appName}/app-debug.apk"
    ignoreWarning = false
    useSign = true
    dex {
        dexMode = "jar"
        pattern = ["classes*.dex"]
        loader = []
    }
    lib {
        pattern = ["lib/*/*.so"]
    }

    res {
        pattern = ["res/*", "r/*", "assets/*", "resources.arsc", "AndroidManifest.xml"]
        ignoreChange = []
        largeModSize = 100
    }

    packageConfig {
    }
    sevenZip {
        zipArtifact = "com.tencent.mm:SevenZip:1.1.10"
//        path = "/opt/homebrew/bin/7za"
    }
    buildConfig {
        keepDexApply = true
        //tinkerId = "1.0.1-patch"
        //applyMapping = "${bakPath}/${appName}/app-debug-mapping.txt" //  可选,设置mapping文件,建议保持旧apk的proguard混淆方式
        //applyResourceMapping = "${bakPath}/${appName}/app-debug-R.txt" // 可选,设置R.txt文件,通过旧apk文件保持ResId的分配
    }

    //from 1.9.14.5
    // for minSdk >= 21 add two value
    allowLoaderInAnyDex = true
    removeLoaderForAllDex = true
}

堆栈/日志:

TINKER_ID正常的打包构建信息.txt 存在问题的构建信息.txt

seapeak233 commented 2 years ago

最新情况,跟 autoGenerateTinkerId = true 无关,指定tinkerId 也没法打进apk的manifest

bushangkoukou commented 2 years ago

+1,目前也遇到这样的问题,暂时先放弃了热修复功能,不知道官方是否已经修复此问题了

TIANYUANXIXUE commented 5 months ago

我也遇到了这样的问题,在ci上正常使用了一段时间以后突然出现的,随机丢失tinkerid,请问大家找到解决方法了吗?