background

This article mainly introduces the use of the latest Bugly, please refer to the official document for detailed operation steps, this article will not repeat.

1. Introduce the latest bugly dependency packs

(1) The project outer layer build.gradle Bugly is introduced

classpath "com.tencent.bugly:tinker-support:latest.release"
Copy the code

Note: it is better to specify the latest version, not the specific version. If you need to specify, please refer to relevant documents and keep tinker Sdk consistent, otherwise an exception will be reported.

(2) The inner build.gradle dependency is introduced

The compile "com. Android. Support: multidex:" 1.0.1 / / dex configuration / / comment out the original bugly warehouse / / compile 'com. Tencent. Bugly: crashreport: latest. Release'. / / the latest release to refer to the latest version number, you can also specify the version number, For example 1.3.4 compile 'com. Tencent. Bugly: crashreport_upgrade: 1.3.6' / / specified tinker rely on version (note: After the app is upgraded to version 1.3.5, Built-in tinker) no longer compile 'com. Tencent. Tinker: tinker - android - lib: 1.9.9' compile 'com. Tencent. Bugly: nativecrashreport: latest. Release'. / / the latest release to refer to the latest version number, you can also specify the version number, such as 2.2.0Copy the code

(3) Create the tinker-support.gradle script file

apply plugin: Def bakPath = file("${buildDir}/bakApk/") /** * def baseApkDir = "App-0130-14-44-01" /** * See */ tinkerSupport {// Enable tinker-support, default value true enable = true // Specify the archive directory, Default Value Subdirectory of the current Module tinker autoBackupApkDir = "${bakPath}" // Whether to enable the function of overwriting tinkerPatch configurations. The default value is false. Without adding tinkerPatch overrideTinkerPatchConfiguration = true / / compile patches, must specify the baseline version of the apk, the default value is empty if / / is empty, // @{link tinkerpatch. oldApk} baseApk = "${bakPath}/${baseApkDir}/wanAndroid-release.apk" // ApplyMapping baseApkProguardMapping = "${bakPath}/${baseApkDir}/app-release-mapping.txt" // ApplyResourceMapping baseApkResourceMapping = "${bakPath}/${baseApkDir}/ app-release-r.txt "// Base package Base patch package patch // Specify a different tinkerId for both base and patch packages. TinkerId = "patch-1.0.2" // buildAllFlavorsDir = "${bakPath}/${baseApkDir}" // Whether to enable the consolidation mode, The default value is false.(supported starting from Tinker-spport 1.0.7) // isProtectedApp = true // Whether to enable reflection Application mode enableProxyApplication = true // Whether new non-export activities are supported (note: SupportHotplugComponent = true} /** * Generally speaking, the following parameters do not need to be modified * For details, 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 / 7 za"} buildConfig {keepDexApply = false / / tinkerId = "1.0.1-base" //applyMapping = "${bakPath}/${appName}/app-release-mapping. TXT "// Optional, set the mapping file, //applyResourceMapping = "${bakPath}/${appName}/ app-release-r.tb "// Optional, set r.tb file, Keep ResId allocations through old APK files}}Copy the code

** Note the above parameters.

1. BaseApkDir =” XXXX “// Indicates the directory where the base package is now packaged.

  1. BaseApk = “bakPath/{bakPath}/bakPath/{baseApkDir}/wanAndroid-release.apk” // Packaged application name

  2. TinkerId = “patch-1.0.2”

// Whether to enable reflection Application mode. If the value is false, refer to the document. EnableProxyApplication = true

Gradle is an internal thinker. Gradle is an internal thinker. Gradle is an internal thinker

// Apply from: 'tinker-support.gradle'Copy the code

(5) Configure the application package signature file

signingConfigs { releaseConfig { keyAlias 'key' keyPassword '123456' storeFile file('.. /test.jks') storePassword '123456' } } buildTypes { release { // proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.releaseConfig android.applicationVariants.all { variant -> // Update to Android Studio 3.3 Gradle 4.10.1 varie.elsion. all {outputFileName = "wanAndroid-release.apk"}}}}Copy the code

(6) Create an Application

Class App :Application(){// Define static variable companion object{var context: Context by Delegates.notNull( ) lateinit var instance: Application } override fun onCreate() { super.onCreate() instance=this context=this; Bugly.init(context, "your appId", true); } override fun attachBaseContext(base: Context?) { super.attachBaseContext(base) // you must install multiDex whatever tinker is installed! MultiDex.install(base); // installTinker beta.installtinker (); }}Copy the code

(7) Pack basic formal packages

Select Gradle-> App -> Tasks -> Other ->assembleRelease on the right to pack it as an official package and install the application on the phone

(8) thinker-support Pack the patch package

After execution, upload the patch file under app\build\outputs\patch\xxx.patch_signed_7zip

(9) Deliver the patch package

If the delivered number is displayed, the delivery is successful.

End: Writing a blog is not easy, if it helps you please manually like.