当前位置:网站首页>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);
}
}
边栏推荐
猜你喜欢
OpenMLDB Pulsar Connector: Efficiently connect real-time data to feature engineering
Thesis unscramble TransFG: A Transformer Architecture for Fine - grained Recognition
stack stack
经纬度求距离
OpenMLDB v0.5.0 发布 | 性能、成本、灵活性再攀高峰
开源之夏 2022 火热来袭 | 欢迎报名 OpenMLDB 社区项目~
Event Preview | On April 23, a number of wonderful sharing sessions of OpenMLDB will come, which will live up to the good time of the weekend
The third phase of the contributor task is wonderful
Jetpack使用异常问题集锦
【无标题】
随机推荐
开源之夏 2022 火热来袭 | 欢迎报名 OpenMLDB 社区项目~
127.0.0.1 connection refused
helm安装
使用adb命令管理应用
Js method commonly used objects and attributes
Day 79
STM32-中断优先级管理NVIC
栈stack
Regular expression replacement for batch quick modification code
OpenMLDB: Consistent production-level feature computing platform online and offline
STM32F4-正点原子探索者-SYSTEM文件夹下的delay.c文件内延时函数详解
Day 80
Some formulas for system performance and concurrency
Jetpack use exception problem collection
USB中用NRZI来编码数据
C语言实现简易扫雷(附带源码)
[Meetup Preview] OpenMLDB+OneFlow: Link feature engineering to model training to accelerate machine learning model development
Node 踩坑之80端口被占用
Day 73
Minutes of OpenMLDB Meetup No.2