bugly android8.1加固,2020-09-27 Bugly Android热更新使用指南
戳我查看 DEMO
Bugly Android热更新使用指南 官方文档
视频教程
第一步:添加插件依赖
工程根目录下“build.gradle”文件中添加:
buildscript {
repositories {
jcenter()
}
dependencies {
// tinkersupport插件, 其中lastest.release指拉取最新版本,也可以指定明确版本号,例如1.0.4
classpath "com.tencent.bugly:tinker-support:1.2.0"
}
}
第二步:集成SDK
添加 tinker-support.gradle 内容如下所示(示例配置):
注:您需要在同级目录下创建tinker-support.gradle这个文件哦。
/**
* Bugly Android热更新详解:
* https://bugly.qq.com/docs/user-guide/instruction-manual-android-hotfix-demo/
*/
apply plugin: 'com.tencent.bugly.tinker-support'
def bakPath = file("${buildDir}/bakApk/")
/**
* 此处填写每次构建生成的基准包目录
*/
def baseApkDir = "app-0927-13-59-50"
/**
* 构建基准包和补丁包都要指定不同的tinkerId,并且必须保证唯一性
*/
def tinkerIdV = "base-1.1.5"
/**
* 对于插件各参数的详细解析请参考
*/
tinkerSupport {
// 开启tinker-support插件,默认值true
enable = true
// 指定归档目录,默认值当前module的子目录tinker
autoBackupApkDir = "${bakPath}"
// 是否启用覆盖tinkerPatch配置功能,默认值false
// 开启后tinkerPatch配置不生效,即无需添加tinkerPatch
overrideTinkerPatchConfiguration = true
//建议设置true,用户就不用再自己管理tinkerId的命名,插件会为每一次构建的base包自动生成唯一的tinkerId,默认命名规则是versionname.versioncode_时间戳
//具体参考https://github.com/BuglyDevTeam/Bugly-Android-Demo/wiki/Tinker-ID%E8%AF%A5%E6%80%8E%E4%B9%88%E8%AE%BE%E7%BD%AE
autoGenerateTinkerId = true
// 构建基准包和补丁包都要指定不同的tinkerId,并且必须保证唯一性
tinkerId = "if autoGenerateTinkerId=true ,no need set here tinkerIdV"
// 编译补丁包时,必需指定基线版本的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"
// 构建多渠道补丁时使用
// buildAllFlavorsDir = "${bakPath}/${baseApkDir}"
// 是否启用加固模式,默认为false.(tinker-spport 1.0.7起支持)
isProtectedApp = true
// 是否开启反射Application模式
enableProxyApplication = false
// 是否支持新增非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 {
//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的分配
}
}
gradle配置
在app module的“build.gradle”文件中添加(示例配置):
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
def keystorePropertiesFile = rootProject.file("keystore.properties")
// Initialize a new Properties() object called keystoreProperties.
def keystoreProperties = new Properties()
// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
compileSdkVersion rootProject.ext.android.compileSdkVersion
buildToolsVersion rootProject.ext.android.buildToolsVersion
defaultConfig {
applicationId rootProject.ext.android.applicationId
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode rootProject.ext.android.versionCode
versionName rootProject.ext.android.versionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
minifyEnabled false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
//其中latest.release指代最新版本号,也可以指定明确的版本号,例如1.2.0
implementation 'com.tencent.bugly:crashreport_upgrade:latest.release'
//其中latest.release指代最新版本号,也可以指定明确的版本号,例如2.2.0
implementation 'com.tencent.bugly:nativecrashreport:latest.release'
// 多dex配置
implementation 'androidx.multidex:multidex:2.0.1'
// 指定tinker依赖版本(注:应用升级1.3.5版本起,不再内置tinker)
implementation 'com.tencent.tinker:tinker-android-lib:1.9.14.3'
}
// 依赖插件脚本
apply from: 'tinker-support.gradle'
第三步:初始化SDK
配置 enableProxyApplication = false 官方推荐方式 兼容会好点
image.png
自定义Application
class AppApplication : TinkerApplication(
ShareConstants.TINKER_ENABLE_ALL, "com.drak.course.ApplicationLike",
"com.tencent.tinker.loader.TinkerLoader", false
)
class ApplicationLike(
application: Application?, tinkerFlags: Int,
tinkerLoadVerifyFlag: Boolean, applicationStartElapsedTime: Long,
applicationStartMillisTime: Long, tinkerResultIntent: Intent?
) : DefaultApplicationLike(
application,
tinkerFlags,
tinkerLoadVerifyFlag,
applicationStartElapsedTime,
applicationStartMillisTime,
tinkerResultIntent
) {
override fun onCreate() {
super.onCreate()
// 这里实现SDK初始化,appId替换成你的在Bugly平台申请的appId
// 调试时,将第三个参数改为true
Bugly.init(application, "b980a3e9c9", true)
}
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
override fun onBaseContextAttached(base: Context) {
super.onBaseContextAttached(base)
// you must install multiDex whatever tinker is installed!
MultiDex.install(base)
// 安装tinker
// TinkerManager.installTinker(this); 替换成下面Bugly提供的方法
Beta.installTinker(this)
}
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
fun registerActivityLifecycleCallback(callbacks: ActivityLifecycleCallbacks?) {
application.registerActivityLifecycleCallbacks(callbacks)
}
}
第四步:AndroidManifest.xml配置
权限配置
升级相关 Activity配置
android:name="com.tencent.bugly.beta.ui.BetaActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale"
android:theme="@android:style/Theme.Translucent"/>
android:name="androidx.core.content.FileProvider"
android:authorities="com.tencent.bugly.hotfix.fileProvider"
android:exported="false"
android:grantUriPermissions="true">
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
在res目录新建xml文件夹,创建provider_paths.xml文件如下
第五步:混淆配置
-dontwarn com.tencent.bugly.**
-keep public class com.tencent.bugly.**{*;}
# tinker混淆规则
-dontwarn com.tencent.tinker.**
-keep class com.tencent.tinker.** { *; }
以上配置部分就完成了 对第一次使用的童鞋建议直接复制 不需要修改,避免出错!
bugly android8.1加固,2020-09-27 Bugly Android热更新使用指南相关推荐
- Android热更新初探,Bugly热更新的集成和使用(让你的应用轻松具备热更新能力)
介绍 在介绍Bugly之前,需要先向大家简单介绍下一些热更新的相关内容.当前市面的热补丁方案有很多,其中比较出名的有阿里的AndFix.美团的Robust以及QZone的超级补丁方案.但它们都存在 ...
- android热更新bugly
工作中偶尔会遇到的场景:当一个App发布之后,突然发现了一个严重bug需要进行紧急修复,这时候公司各方就会忙得焦头烂额:重新打包App.测试.向各个应用市场和渠道换包.提示用户升级.用户下载.覆盖安装 ...
- android 热更新之腾讯Bugly 及所遇问题的修改总结
具体的操作步骤,其实与官网上的一致 这里把官网贴一下腾讯热修复官网 第一步:添加插件依赖 工程根目录下"build.gradle"文件中添加: buildscript {repos ...
- Bugly Android热更新总结篇
AndroidManifest文件 新增四大组件 关于Tinker的能力,大家可以移步看下Tinker Wiki. 开发者为什么这么热衷于热更新? 热更新解决了开发者的一个痛点就是程序逻辑出现bug了 ...
- Android热更新Tinker + 多渠道打包 + 加固的流程详解
一.Tinker热修复 关于热修复的作用,不用多说了,一句话概括就是通过让用户无感的方式来修复线上应用的bug.这里介绍的是微信Tinker. 下面的接入方式都是参考自Tinker官方文档来.我这里主 ...
- 2020.09.27@微众银行
1.近似值查询 72% 近似值查询 时间限制: 4000MS 内存限制: 589824KB 题目描述: 给定一个长度为n的数组a,我们定义一个数x的近似值是在数组a中与x的差值的绝对值最小,如果两个数 ...
- bugly热更新、多渠道集成及加固问题
Bugly Android热更新使用指南–>大部分步骤按照文档即可:官方文档 ========================================================== ...
- walle多渠道打包+Tinker(bugly)热更新集成+360加固(乐固)
这三个东东是干啥的相信大家都有所耳闻了,如果你没有听说过,请出门左拐,百度一下你就知道.这里不对这三个东东具体的集成方式做详细的介绍,因为官方文档已经写的很详细了,主要是对同时使用这三个东东时所需要注 ...
- bugly热更新加固应用失败详解
最近做了一个热更新的功能,前几天把热更新的坑全部踩了一遍之后,热更新功能得以使用,但是昨天又发现了一个新的问题,就是热更新成功,但是加固后的包就不行了.注意:我这里是用的360和乐固加固测试的. 最初 ...
最新文章
- 黄金分割算法求函数的极值C++实现
- 小米与格力的10亿豪赌!
- 拥有属于你的“尬聊”机器人
- C语言程序care用法,词汇精选:care的用法和辨析
- 学习日记2、easyui treeGrid属性及时间
- NYOJ-+-字符串(贪心)
- 反编译androd的apk文件
- mysql允许远程访问的用户
- MSDEV.EXE-应用程序错误解决办法
- 改用Hamibot-艳云脚本云控系统
- 算24点的一般方法及例题
- 植物大战僵尸-阳光数目修改及阳光基址
- cos三次方积分_cos三次方的定积分
- 初级程序员最应避免的 7 大错误
- delphi 画图表,曲线图
- word加密文档忘记密码了如何打开
- R语言用标准最小二乘OLS,广义相加模型GAM ,样条函数进行逻辑回归LOGISTIC分类...
- Java---NullPoint经验解析
- 『征文精选』技术翻译与术语管理技术:专业人说专业话
- 程序员成长之路(四)之有用的网址
热门文章
- 德国商业经济金融发展史
- win10编译caffe跑faster-rcnn(cuda7.5)
- Win10 64位安装SQL2000(个人版)
- 能过ChilkatDotNet4.dll组件,开发SFTP,上传下载功能。
- 为什么叫C++而不叫++C ?
- 简单的C#字符串数组转字符串方法
- Oracle TNS-12535: TNS: 操作超时
- 最大素数的c语言,for语句计算输出10000以内最大素数怎么搞最简单??各位大神们...
- MySQL数据库基础(mysql数据类型、数据表的操作)
- 简单循迹小车实验心得_智能循迹小车总结 智能循迹小车报告.doc