当前位置:网站首页>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
边栏推荐
- Popular cross domain
- 商城风格也可以很多变,DIY了解一下!
- Vscode有什么好用的插件?
- Mt60b1g16hc-48b:a micron memory particles FBGA code d8bnk[easy to understand]
- Rapport de la main - d'oeuvre du Conseil de développement de l'aecg air32f103cbt6
- 一文带你搞懂 JWT 常见概念 & 优缺点
- Free books! AI across the Internet paints old photos. Here is a detailed tutorial!
- Client development (electron) system level API usage 2
- Take you to the open source project of smart home: the preliminary configuration of zhiting home cloud and home assistant+ homebridge
- [problem solving] dialogfragment can not be attached to a container view
猜你喜欢

Read the configuration, explain the principle and read the interview questions. I can only help you here...

VectorDraw Developer Framework 10.1001 Crack

Resolve Visio and office365 installation compatibility issues
MySQL installation tutorial
Super comprehensive custom deep copy function
Take you to the open source project of smart home: the preliminary configuration of zhiting home cloud and home assistant+ homebridge
Introduction to database transactions
Desktop development (Tauri) opens the first chapter

Asynchronous processing of error prone points

Educational administration system development (php+mysql)
随机推荐
In the wechat environment, H5 jumps to the specified page of the applet
Built in methods for data types
Share the code technology points and software usage of socket multi client communication
合宙Air32F103CBT6开发板上手报告
Golang uses Mongo driver operation - increase (Advanced)
Jz-065 path in matrix
Write one file to the marked location of another file
商城风格也可以很多变,DIY了解一下!
说下你对方法区演变过程和内部结构的理解
The style of the mall can also change a lot. DIY can learn about it!
什么是oa
Servlet详解
Sleep formula: how to cure bad sleep?
Why does golang's modification of slice data affect the data of other slices?
Deep learning pytorch cifar10 dataset training "suggestions collection"
报错:homebrew-core is a shallow clone
不要再「外包」AI 模型了!最新研究发现:有些破坏机器学习模型安全的「后门」无法被检测到
不要小看了积分商城,它的作用可以很大!
Problems caused by using ApplicationContext to render layout
What is OA