解決:Bugly發(fā)布熱更新時(shí)说搅,提示沒有對(duì)應(yīng)基線版本
在集成bugly熱修復(fù)框架時(shí),按照官方教程虏等,《Bugly Android熱更新使用指南》的bugly配置蜓堕,發(fā)現(xiàn)當(dāng)后期要發(fā)布熱更新時(shí)抛虏,提示"未匹配到可應(yīng)用補(bǔ)丁包的App版本,請(qǐng)確認(rèn)補(bǔ)丁包的基線版本是否已發(fā)布"套才。
找了很久終于發(fā)現(xiàn)是因?yàn)楣俜绞褂弥改仙?=少了配置項(xiàng)==迂猴,官方教程是這樣的:
apply plugin: 'com.tencent.bugly.tinker-support'
def bakPath = file("${buildDir}/bakApk/")
/**
* 此處填寫每次構(gòu)建生成的基準(zhǔn)包目錄
*/
def baseApkDir = "app-0208-15-10-00"
/**
* 對(duì)于插件各參數(shù)的詳細(xì)解析請(qǐng)參考
*/
tinkerSupport {
// 開啟tinker-support插件,默認(rèn)值true
enable = true
// 指定歸檔目錄背伴,默認(rèn)值當(dāng)前module的子目錄tinker
autoBackupApkDir = "${bakPath}"
// 是否啟用覆蓋tinkerPatch配置功能沸毁,默認(rèn)值false
// 開啟后tinkerPatch配置不生效,即無需添加tinkerPatch
overrideTinkerPatchConfiguration = true
// 編譯補(bǔ)丁包時(shí)傻寂,必需指定基線版本的apk息尺,默認(rèn)值為空
// 如果為空,則表示不是進(jìn)行補(bǔ)丁包的編譯
// @{link tinkerPatch.oldApk }
baseApk = "${bakPath}/${baseApkDir}/app-release.apk"
// 對(duì)應(yīng)tinker插件applyMapping
baseApkProguardMapping = "${bakPath}/${baseApkDir}/app-release-mapping.txt"
// 對(duì)應(yīng)tinker插件applyResourceMapping
baseApkResourceMapping = "${bakPath}/${baseApkDir}/app-release-R.txt"
// 構(gòu)建基準(zhǔn)包和補(bǔ)丁包都要指定不同的tinkerId疾掰,并且必須保證唯一性
tinkerId = "base-1.0.1"
// 構(gòu)建多渠道補(bǔ)丁時(shí)使用
// buildAllFlavorsDir = "${bakPath}/${baseApkDir}"
// 是否開啟反射Application模式
enableProxyApplication = false
}
/**
* 一般來說,我們無需對(duì)下面的參數(shù)做任何的修改
* 對(duì)于各參數(shù)的詳細(xì)介紹請(qǐng)參考:
* https://github.com/Tencent/tinker/wiki/Tinker-%E6%8E%A5%E5%85%A5%E6%8C%87%E5%8D%97
*/
tinkerPatch {
//oldApk ="${bakPath}/${appName}/app-release.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 = "/usr/local/bin/7za"
}
buildConfig {
keepDexApply = false
//tinkerId = "1.0.1-base"
//applyMapping = "${bakPath}/${appName}/app-release-mapping.txt" // 可選搂誉,設(shè)置mapping文件,建議保持舊apk的proguard混淆方式
//applyResourceMapping = "${bakPath}/${appName}/app-release-R.txt" // 可選静檬,設(shè)置R.txt文件炭懊,通過舊apk文件保持ResId的分配
}
}
正確的應(yīng)該是:
apply plugin: 'com.tencent.bugly.tinker-support'
def bakPath = file("${buildDir}/bakApk/")
/**
* 此處填寫每次構(gòu)建生成的基準(zhǔn)包目錄
*/
def baseApkDir = "app-0208-15-10-00"
/**
* 對(duì)于插件各參數(shù)的詳細(xì)解析請(qǐng)參考
*/
tinkerSupport {
// 開啟tinker-support插件,默認(rèn)值true
enable = true
// tinkerEnable功能開關(guān)
tinkerEnable = true
// 指定歸檔目錄拂檩,默認(rèn)值當(dāng)前module的子目錄tinker
autoBackupApkDir = "${bakPath}"
// 是否啟用覆蓋tinkerPatch配置功能侮腹,默認(rèn)值false
// 開啟后tinkerPatch配置不生效,即無需添加tinkerPatch
overrideTinkerPatchConfiguration = true
// 編譯補(bǔ)丁包時(shí)稻励,必需指定基線版本的apk父阻,默認(rèn)值為空
// 如果為空,則表示不是進(jìn)行補(bǔ)丁包的編譯
// @{link tinkerPatch.oldApk }
baseApk = "${bakPath}/${baseApkDir}/app-release.apk"
// 對(duì)應(yīng)tinker插件applyMapping
baseApkProguardMapping = "${bakPath}/${baseApkDir}/app-release-mapping.txt"
// 對(duì)應(yīng)tinker插件applyResourceMapping
baseApkResourceMapping = "${bakPath}/${baseApkDir}/app-release-R.txt"
// 構(gòu)建基準(zhǔn)包跟補(bǔ)丁包都要修改tinkerId望抽,主要用于區(qū)分
tinkerId = "base-1.0.1"
// 打多渠道補(bǔ)丁時(shí)指定目錄
// buildAllFlavorsDir = "${bakPath}/${baseApkDir}"
enableProxyApplication = true
}
/**
* 一般來說,我們無需對(duì)下面的參數(shù)做任何的修改
* 對(duì)于各參數(shù)的詳細(xì)介紹請(qǐng)參考:
* https://github.com/Tencent/tinker/wiki/Tinker-%E6%8E%A5%E5%85%A5%E6%8C%87%E5%8D%97
*/
tinkerPatch {
tinkerEnable = true
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 = "/usr/local/bin/7za"
}
buildConfig {
keepDexApply = false
// tinkerId = "base-2.0.1"
}
}
==注意官方教程是少了這個(gè):==
// tinkerEnable功能開關(guān)
tinkerEnable = true
另外加矛,一般我們的MyApplication都不會(huì)直接繼承自bugly要求的TinkerApplication,而是在自己的MyApplication中配置相關(guān)項(xiàng)煤篙,所以還需==注意==:
enableProxyApplication = true
其他方面按照官方指南來就好啦~~~~