一、微信Tinker
说说碰到的几个坑吧
重点内容坑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'
}
}