当前位置:网站首页>Bugly hot update usage
Bugly hot update usage
2022-06-25 16:01:00 【Crazy D black bull】
Official document :https://bugly.qq.com/docs/user-guide/instruction-manual-android-hotfix/?v=20181014122344
website

1. add to classpath

2. Add dependency

3. create a file

The contents of the document are as follows
apply plugin: 'com.tencent.bugly.tinker-support'
def bakPath = file("${buildDir}/bakApk/")
/**
* Fill in the base package directory generated by each build
*/
def baseApkDir = "app-1123-15-40-02"
/**
* For detailed analysis of plug-in parameters, please refer to
*/
tinkerSupport {
// Turn on tinker-support plug-in unit , The default value is true
enable = true
// Specify archive Directory , Default value current module A subdirectory tinker
autoBackupApkDir = "${bakPath}"
autoGenerateTinkerId = true
// Enable overwrite or not tinkerPatch Configuration functions , The default value is false
// After opening tinkerPatch Configuration does not work , No need to add tinkerPatch
overrideTinkerPatchConfiguration = true
// When compiling the patch package , You must specify the baseline version of apk, The default value is empty
// If it is empty , It means that the patch package is not compiled
// @{link tinkerPatch.oldApk }
baseApk = "${bakPath}/${baseApkDir}/app-release.apk"
// Corresponding tinker plug-in unit applyMapping
baseApkProguardMapping = "${bakPath}/${baseApkDir}/app-release-mapping.txt"
// Corresponding tinker plug-in unit applyResourceMapping
baseApkResourceMapping = "${bakPath}/${baseApkDir}/app-release-R.txt"
tinkerId = "1.0.2-patch"
// buildAllFlavorsDir = "${bakPath}/${baseApkDir}"
// Whether to turn on reinforcement mode , The default is false
// isProtectedApp = true
enableProxyApplication = false
supportHotplugComponent = true
}
/**
* Generally speaking , We don't need to make any changes to the following parameters
* For detailed introduction of each parameter, please refer to :
* 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-patch"
//applyMapping = "${bakPath}/${appName}/app-release-mapping.txt" // Optional , Set up mapping file , It is suggested to keep old apk Of proguard The way of confusion
//applyResourceMapping = "${bakPath}/${appName}/app-release-R.txt" // Optional , Set up R.txt file , Through the old apk Keep the document ResId The distribution of
}
}4. establish SampleApplicationLike class
public class SampleApplicationLike extends DefaultApplicationLike {
public static final String TAG = "Tinker.SampleApplicationLike";
public SampleApplicationLike(Application application, int tinkerFlags,
boolean tinkerLoadVerifyFlag, long applicationStartElapsedTime,
long applicationStartMillisTime, Intent tinkerResultIntent) {
super(application, tinkerFlags, tinkerLoadVerifyFlag, applicationStartElapsedTime,
applicationStartMillisTime, tinkerResultIntent);
}
@Override
public void onCreate() {
super.onCreate();
// Set whether to turn on the hot update capability , The default is true
Beta.enableHotfix = true;
// Set whether to download patches automatically , The default is true
Beta.canAutoDownloadPatch = true;
// Set whether to automatically synthesize patches , The default is true
Beta.canAutoPatch = true;
// Set whether to prompt the user to restart , The default is false
Beta.canNotifyUserRestart = true;
// Patch callback interface
Beta.betaPatchListener = new BetaPatchListener() {
@Override
public void onPatchReceived(String patchFile) {
Toast.makeText(getApplication(), " Patch download address " + patchFile, Toast.LENGTH_SHORT).show();
}
@Override
public void onDownloadReceived(long savedLength, long totalLength) {
Toast.makeText(getApplication(),
String.format(Locale.getDefault(), "%s %d%%",
Beta.strNotificationDownloading,
(int) (totalLength == 0 ? 0 : savedLength * 100 / totalLength)),
Toast.LENGTH_SHORT).show();
}
@Override
public void onDownloadSuccess(String msg) {
Toast.makeText(getApplication(), " Patch download successful ", Toast.LENGTH_SHORT).show();
}
@Override
public void onDownloadFailure(String msg) {
Toast.makeText(getApplication(), " Patch download failed ", Toast.LENGTH_SHORT).show();
}
@Override
public void onApplySuccess(String msg) {
Toast.makeText(getApplication(), " Patch applied successfully ", Toast.LENGTH_SHORT).show();
}
@Override
public void onApplyFailure(String msg) {
Toast.makeText(getApplication(), " Patch application failed ", Toast.LENGTH_SHORT).show();
}
@Override
public void onPatchRollback() {
}
};
// Set up development equipment , The default is false, Upload the patch if the distribution range is specified as “ The development of equipment ”, This interface needs to be called to identify the development device
Bugly.setIsDevelopmentDevice(getApplication(), true);
// Multichannel demand into
// String channel = WalleChannelReader.getChannel(getApplication());
// Bugly.setAppChannel(getApplication(), channel);
// Realize here SDK initialization ,appId Replace it with yours in Bugly Platform application appId
Bugly.init(getApplication(), "21537317f9", true);
}
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
public void onBaseContextAttached(Context base) {
super.onBaseContextAttached(base);
// you must install multiDex whatever tinker is installed!
MultiDex.install(base);
// TODO: install tinker
Beta.installTinker(this);
}
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void registerActivityLifecycleCallback(
Application.ActivityLifecycleCallbacks callbacks) {
getApplication().registerActivityLifecycleCallbacks(callbacks);
}
@Override
public void onTerminate() {
super.onTerminate();
Beta.unInit();
}
}4 establish SampleApplication Inherit SampleApplicationLike
Be careful : Parameters 2 Created for yourself SampleApplicationLike route
package com.mybugly.hotfix;
import com.tencent.tinker.loader.app.TinkerApplication;
import com.tencent.tinker.loader.shareutil.ShareConstants;
/**
* Customize Application.
*
* Be careful : This class integrates TinkerApplication class , There's no operation in this , all Application The code will be put into ApplicationLike Among the inheritance classes <br/>
* <pre>
* Argument parsing :
* Parameters 1:int tinkerFlags Express Tinker Types of support dex only、library only or all suuport,default: TINKER_ENABLE_ALL
* Parameters 2:String delegateClassName Application proxy class Fill in your custom ApplicationLike
* Parameters 3:String loaderClassName Tinker The loader of , Just use the default
* Parameters 4:boolean tinkerLoadVerifyFlag load dex perhaps lib Whether the validation md5, The default is false
* </pre>
*/
public class SampleApplication extends TinkerApplication {
public SampleApplication() {
super(ShareConstants.TINKER_ENABLE_ALL, "com.mybugly.hotfix.SampleApplicationLike",
"com.tencent.tinker.loader.TinkerLoader", false);
}
}5. Add permissions to the manifest file

6、 Generate benchmark package

7. Generate patches

8. Upload patch file

9. Release portal

github Source code :https://github.com/crazysnail123/my_buglyhotfix
边栏推荐
- 元宇宙系统的概念解析
- Sword finger offer 04 Find in 2D array
- Sword finger offer 10- I. Fibonacci sequence
- Message format of Modbus (PLC)
- leetcode-8. String to integer (ATOI)
- 免费送书啦!火遍全网的AI给老照片上色,这里有一份详细教程!
- Educational administration system development (php+mysql)
- 商城风格也可以很多变,DIY了解一下!
- Consumer and producer cases of inter thread synchronization (condition variable)
- 教务系统开发(PHP+MySQL)
猜你喜欢

AutoK3s v0.5.0 发布 延续简约和友好

Uncover gaussdb (for redis): comprehensive comparison of CODIS

TFIDF与BM25

合宙Air32F103CBT6開發板上手報告
Why is it said that restarting can solve 90% of the problems

golang使用mongo-driver操作——增(进阶)

Alvaria宣布客户体验行业资深人士Jeff Cotten担任新首席执行官
Introduction to database transactions
Take you to the open source project of smart home: the preliminary configuration of zhiting home cloud and home assistant+ homebridge

Sleep formula: how to cure bad sleep?
随机推荐
普通人的2022春招总结(阿里、腾讯offer)
10款超牛Vim插件,爱不释手了
有哪些新手程序员不知道的小技巧?
元宇宙系统的概念解析
Deep learning pytorch cifar10 dataset training "suggestions collection"
数据存储和传输文件之XML使用和解析详解
面试官:你简历上说精通mysql,那你说下聚簇/联合/覆盖索引、回表、索引下推
商城风格也可以很多变,DIY 了解一下!
Traversal and branch judgment of JS (case on June 24, 2022)
Rxjs TakeUntil 操作符的学习笔记
《睡眠公式》:怎么治睡不好?
Classic deadlock scenario of multithreading and its solution (philosopher dining problem)
Cloning and importing DOM nodes
TFIDF and BM25
Power representation in go language
地理位置数据存储方案——Redis GEO
Startup and shutdown of appium service
什么是NFT数字藏品?
不要小看了积分商城,它的作用可以很大!
Describe your understanding of the evolution process and internal structure of the method area