当前位置:网站首页>The whole process of Tinker access --- configuration
The whole process of Tinker access --- configuration
2022-08-11 06:37:00 【rest of my life love static】
接入全流程
配置Gradle
1、项目gradle
2、app moudle
apply plugin: 'com.android.application'
android {
signingConfigs {
release {
keyAlias 'tinker'
keyPassword 'tinker123456'
storeFile file('tinkerDemo.jks')
storePassword 'tinker123456'
}
}
compileSdkVersion 28
defaultConfig {
applicationId "smt.com.tinkerdemo"
minSdkVersion 21
targetSdkVersion 28
versionCode 0
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
// 编译选项
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
// recommend
dexOptions {
jumboMode = true
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// 多dex配置
implementation 'com.android.support:multidex:1.0.2'
// 本地集成aar方式
// compile(name: 'bugly_crashreport_upgrade-1.3.6', ext: 'aar')
// Remote dependency integration(推荐)
implementation 'com.tencent.bugly:crashreport_upgrade:1.3.6'
// 指定tinker依赖版本(注:应用升级1.3.5版本起,不再内置tinker)
implementation 'com.tencent.tinker:tinker-android-lib:1.9.9'
}
// 依赖插件脚本
apply from: 'tinker-support.gradle'
3、tinker-support.gradle配置
apply plugin: 'com.tencent.bugly.tinker-support'
def bakPath = file("${buildDir}/bakApk/")
/**
* 此处填写每次构建生成的基准包目录
*/
def baseApkDir = "app-0716-17-36-08" [email protected]
/**
* 对于插件各参数的详细解析请参考
*/
tinkerSupport {
// 开启tinker-support插件,默认值true
enable = true
// 指定归档目录,默认值当前module的子目录tinker
autoBackupApkDir = "${bakPath}"
// 是否启用覆盖tinkerPatch配置功能,默认值false
// 开启后tinkerPatch配置不生效,即无需添加tinkerPatch
overrideTinkerPatchConfiguration = true [email protected]
// 编译补丁包时,必需指定基线版本的apk,默认值为空
// 如果为空,则表示不是进行补丁包的编译
// @{link tinkerPatch.oldApk }
baseApk = "${bakPath}/${baseApkDir}/app-release.apk"
// 对应tinker插件applyMapping
baseApkProguardMapping = "${bakPath}/${baseApkDir}/app-release-mapping.txt"
// 对应tinker插件applyResourceMapping
baseApkResourceMapping = "${bakPath}/${baseApkDir}/app-release-R.txt"
// 构建基准包和补丁包都要指定不同的tinkerId,并且必须保证唯一性
tinkerId = "patch-1.1.0" ------[email protected]3
// 构建多渠道补丁时使用
// buildAllFlavorsDir = "${bakPath}/${baseApkDir}"
// 是否启用加固模式,默认为false.(tinker-spport 1.0.7起支持)
// isProtectedApp = true
// 是否开启反射Application模式
enableProxyApplication = false [email protected]
// 是否支持新增非export的Activity(注意:设置为true才能修改AndroidManifest文件)
supportHotplugComponent = true
}
/**
* 一般来说,我们无需对下面的参数做任何的修改
* 对于各参数的详细介绍请参考:
* https://github.com/Tencent/tinker/wiki/Tinker-%E6%8E%A5%E5%85%A5%E6%8C%87%E5%8D%97
*/
tinkerPatch { --------------------------------------------------- @5
//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" // 可选,设置mapping文件,建议保持旧apk的proguard混淆方式
//applyResourceMapping = "${bakPath}/${appName}/app-release-R.txt" // 可选,设置R.txt文件,通过旧apk文件保持ResId的分配
}
}
说明
@1:Here is the path to the benchmark package:role is important、很重要、很重要,Its role is that the patch package is under this pathapkThe file is the patch package generated by the benchmark
@2:如果设置为false,则@5The configuration at will not take effect;如果设置为true,则@5The configuration here takes effect
@3:Must be unique here,Both and the current benchmark package,还是之前的版本,Must be unique,唯一性、唯一性、唯一性,Each time a patch package is generated,每次、每次、每次,都要保持唯一
@4:如果设置为true,我们不需要继承TinkerApplication,只需要继承原生Application即可,TinkerReflection will be used,修改Application;如果设置为false,我们需要自定义MyApplicationLike继承DefaultApplicationLike,MyApplication继承TinkerApplication
MyApplicationLike
public class MyApplicationLike extends DefaultApplicationLike {
public MyApplicationLike(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();
Bugly.setIsDevelopmentDevice(getApplication(),true); [email protected]
// 这里实现SDK初始化,appId替换成你的在Bugly平台申请的appId
Bugly.init(getApplication(), "98552355", 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: 安装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();
}
}
@6:This configuration sets the current device as a development device,对应buglyHot update update the patch distribution range.**开发设备:**Patch distribution will only be distributed to the configuration that is called when runningtrue的设备;**全量设备:**Is the patch distributed to all devices
MyApplication
public class MyApplication extends TinkerApplication {
/**
* current build.
*
*/
public MyApplication() {
super(ShareConstants.TINKER_ENABLE_ALL, "smt.com.tinkerdemo.MyApplicationLike",
"com.tencent.tinker.loader.TinkerLoader", false);
}
}
边栏推荐
- 2021-09-11 C language variables and memory allocation
- OpenMLDB + Jupyter Notebook: Quickly Build Machine Learning Applications
- PAT乙级刷题之路
- C语言实现猜数字(附带源码,可直接运行)
- Day 83
- Simple mine sweeping in C language (with source code)
- 【无标题】
- Day 79
- 将一个excel文件中多个sheet页“拆分“成多个“独立“excel文件
- 论文解读:GAN与检测网络多任务/SOD-MTGAN: Small Object Detection via Multi-Task Generative Adversarial Network
猜你喜欢
随机推荐
Day 87
Day 83
实时特征计算平台架构方法论和基于 OpenMLDB 的实践
ARM 汇编指令 ADR 与 LDR 使用
He Kaiming's new work ViTDET: target detection field, subverting the concept of layered backbone
场景驱动的特征计算方式OpenMLDB,高效实现“现算先用”
何凯明新作ViTDET:目标检测领域,颠覆分层backbone理念
vscode插件开发——代码提示、代码补全、代码分析
Real-time Feature Computing Platform Architecture Methodology and Practice Based on OpenMLDB
Day 79
Day 81
STM32-库函数-SetSysClock(void)函数解析-正点原子探索者
gerrit configure SSH Key and account, email information
stack stack
品优购项目实战笔记
JS小技巧,让你编码效率杠杠的,快乐摸鱼
Pinyougou project combat notes
厂商推送平台-华为接入
gerrit 配置SSH Key和账号、邮箱信息
Tinker的自我介绍