Tinker接入心得

一、微信Tinker

参考:
1、微信Demo
2、博客案例1
3、博客案例2

说说碰到的几个坑吧

重点内容坑1:ignoreWarning 问题

Warning:ignoreWarning is false, but resources.arsc is changed, you should use applyResourceMapping mode to build the new apk, otherwise, it may be crash at some times
com.tencent.tinker.build.util.TinkerPatchException: ignoreWarning is false, but resources.arsc is changed, you should use applyResourceMapping mode to build the new apk, otherwise, it may be crash a
t some times

目前的解决方法是在解决方案是将build.gradle中的ignoreWarning = false改为true,如下:

tinkerPatch {
…..
ignoreWarning = true
…..
}

不过既然这是微信开发设置的一个状态值,最好不要更改,系统也提示可能会有风险。

坑2:tinkerId is not set!!!

tinkerId is not set!!!

情况一:tinkerId配置写死了,没有用版本号或可更改的一个变量值,可以用版本号变量来替换
情况二:使用微信demo,tinkerId没有写死的情况,主要是因为没有配置git,因为这是因为配置中有这样一句

String gitRev = 'git rev-parse --short HEAD'.execute(null, project.rootDir).text.trim()

Tinker Github上有这么一句解释:这是因为没有正确的配置IDE的git路径, 若不是通过clone方式下载tinker,需要本地手动commit一次。这里你也可以使用其他字符作为tinkerId;

总结就是,tinkerId需要用字符并且是在git环境下才有效,至于svn,还没试过

二、Bugly三方框架

其实bugly热更新也是使用的tinker,都是腾讯自家产品嘛!

遇到的几个问题:
Q:tinker-support.gradle文件中tinkerId的取值问题

A:官方推荐使用versionName来作为tinkerId的值,如果直接使用android.default.versionname作为版本号,返回为null,后来尝试多种方法都不行,因为打基准包时tinkerId内容包含base字段,打补丁包时tinkerId内容包含patch字段,所以两次都需要改,所以以后升级时手动更换tinkerId值。

Q:打release基准包生成的是unsigned类型的
这里写图片描述

A:主要是gradle环境没有配置好,在build.gradle中添加一下代码段

    signingConfigs {
        debug {
            storeFile file("/Users/messi/Shared/keyStore/bugly.jks")
            storePassword "Smartx123"
            keyAlias "tank"
            keyPassword "Smartx123"
            v2SigningEnabled false
        }

        release {
            storeFile file("/Users/messi/Shared/keyStore/bugly.jks")
            storePassword "Smartx123"
            keyAlias "tank"
            keyPassword "Smartx123"
            v2SigningEnabled true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值