Android Bugly 中的热修复接入方式(坑已找到原因)

配置:
/** 第一步:bugly 热更新配置: 项目中的build.gradle */
jcenter()

/** 第二步:bugly 热更新配置,版本号一定要按照如下标明的填写: 项目中的build.gradle/
/
* 设置tools的gradle 版本 /
classpath "com.android.tools.build:gradle:3.4.0"
/
* tinkersupport插件 */
classpath "com.tencent.bugly:tinker-support:1.1.5"

/** 第三步:bugly 热更新配置: Module中的build.gradle*/
ndk {
//设置支持的SO库架构
abiFilters 'armeabi','x86','armeabi-v7a','x86_64','arm64-v8a'
}

/** 第四步:bugly 热更新配置: Module中的build.gradle,版本号一定要按照如下标明的填写*/
implementation "com.android.support:multidex:1.0.2" // 多dex配置
//注释掉原有bugly的仓库
// 指定tinker依赖版本(注:应用升级1.3.5版本起,不再内置tinker)
implementation 'com.tencent.tinker:tinker-android-lib:1.9.9'


distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.7-all.zip









android:name="com.tencent.bugly.beta.ui.BetaActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale"
android:theme="@android:style/Theme.Translucent" />


android:name=".utils.BuglyFileProvider"
android:authorities="${applicationId}.fileProvider"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="name,authorities,exported,grantUriPermissions">
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"
tools:replace="name,resource"/>

/** 第九步:在utils包中创建命名为BuglyFileProvider类,并继承FileProvider */
public class BuglyFileProvider extends FileProvider {
}

/** 第十步:在res下创建xml目录,并且创建 provider_paths.xml 文件,文件内容如下:*/







/** 第十一步: 在module根目录下即app根目录下创建tinker-support.gradle这个文件,文件内容如下:*/
apply plugin: 'com.tencent.bugly.tinker-support'

def bakPath = file("${buildDir}/bakApk/")

/**

  • 此处填写每次构建生成的基准包目录
    */
    def baseApkDir = "app-1108-15-10-04"

/**

  • 对于插件各参数的详细解析请参考
    /
    tinkerSupport {
    // 开启tinker-support插件,默认值true
    enable = true
    // 自动生成tinkerId, 你无须关注tinkerId,默认为false
    autoGenerateTinkerId = true
    // 指定归档目录,默认值当前module的子目录tinker
    autoBackupApkDir = "{bakPath}{bakPath}/{bakPath}/{bakPath}/{bakPath}/{bakPath}/{bakPath}/{baseApkDir}/app-debug-R.txt{bakPath}/${baseApkDir}"
    // 是否使用加固模式,默认为false
    // isProtectedApp = true
    // 是否采用反射Application的方式集成,无须改造Application
    enableProxyApplication = true
    // 支持新增Activity
    supportHotplugComponent = true
    }
    /
    *
  • 一般来说,我们无需对下面的参数做任何的修改
  • 对于各参数的详细介绍请参考:
  • https://github.com/Tencent/tinker/wiki/Tinker-%E6%8E%A5%E5%85%A5%E6%8C%87%E5%8D%97
    /
    tinkerPatch {
    tinkerEnable = true
    ignoreWarning = false
    useSign = false
    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 = "base-2.0.1"
    }
    }

/** 第十二步:在module的顶部,添加依赖插件脚本 */
apply from: 'tinker-support.gradle'

/** 第十三步:在 tinker-support.gradle 文件中修改如下属性值 */
enableProxyApplication = true

/** 第十四步:在Application 类中初始化热修复补丁 */
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// 这里实现SDK初始化,appId替换成你的在Bugly平台申请的appId
// 调试时,将第三个参数改为true
Bugly.init(this, "900029763", false);
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
// you must install multiDex whatever tinker is installed!
MultiDex.install(base);
// 安装tinker
Beta.installTinker();
}
}

/** 第十五步:混淆 /
-dontwarn com.tencent.bugly.
*
-keep public class com.tencent.bugly.*{;}

tinker混淆规则

-dontwarn com.tencent.tinker.**
-keep class com.tencent.tinker.** { ; }
如果使用了support-v4,需要添加如下规则:
-keep class android.support.
{;}

你可能感兴趣的:(Android Bugly 中的热修复接入方式(坑已找到原因))