### TinkerSupport Plugin Configuration Parameters Source: https://bugly.qq.com/docs/utility-tools/plugin-gradle-hotfix_v=1.0 This section details the various configuration parameters available for the TinkerSupport plugin. These parameters control aspects like enabling the plugin, generating patch IDs, handling hotplug components, specifying file names, managing backup directories, overriding Tinker patch configurations, and defining base APK and mapping files. ```Markdown **tinker-support插件配置** 参数名 | 默认值 | 参数说明 ---|---|--- enable | true | 开启tinker-support插件 autoGenerateTinkerId | false | 自动生成tinkerId supportHotplugComponent | false | 是否支持新增activity targetFileNamePrefix | "" | 指定输出文件前缀 autoBackupApkDir | 'tinker' | 指定归档目录,默认值当前module的子目录tinker overrideTinkerPatchConfiguration | false | 是否启用覆盖tinkerPatch配置功能,开启后tinkerPatch配置不生效,即无需添加tinkerPatch baseApk | "" | 对应tinker插件`oldApk`,编译补丁包时,必需指定基线版本的apk,默认值为空;如果为空,则表示不是进行补丁包的编译 ignoreWarning | false | 如果出现以下的情况,并且ignoreWarning为false,我们将中断编译。因为这些情况可能会导致编译出来的patch包带来风险: 1. minSdkVersion小于14,但是`dexMode`的值为"raw"; 2. 新编译的安装包出现新增的四大组件(Activity, BroadcastReceiver...); 3. 定义在dex.loader用于加载补丁的类不在main dex中; 4. 定义在dex.loader用于加载补丁的类出现修改; 5. resources.arsc改变,但没有使用applyResourceMapping编译。 patchSigning | true | 对应tinker插件`userSign`, 在运行过程中,我们需要验证基准apk包与补丁包的签名是否一致,我们是否需要为你签名。 baseApkProguardMapping | "" | 对应tinker插件`applyMapping`, 可选参数;在编译新的apk时候,我们希望通过保持旧apk的proguard混淆方式,从而减少补丁包的大小。这个只是推荐的,但**设置applyMapping会影响任何的assemble编译** 。 baseApkResourceMapping | "" | 对应tinker插件`applyResourceMapping`, 可选参数;在编译新的apk时候,我们希望通过旧apk的`R.txt`文件保持ResId的分配,这样不仅**可以减少补丁包的大小,同时也避免由于ResId改变导致remote view异常** 。 tinkerId | "" | 在运行过程中,我们需要验证基准apk包的tinkerId是否等于补丁包的tinkerId。这个是决定补丁包能运行在哪些基准包上面,一般来说我们可以使用git版本号、versionName等等。 dexMode | "jar" | 只能是'raw'或者'jar'。 对于'raw'模式,我们将会保持输入dex的格式。 对于'jar'模式,我们将会把输入dex重新压缩封装到jar。如果你的minSdkVersion小于14,你必须选择‘jar’模式,而且它更省存储空间,但是验证md5时比'raw'模式耗时()。 dexPattern | ["classes*.dex", "assets/secondary-dex-?.jar"] | 需要处理dex路径,支持*、?通配符,必须使用'/'分割。路径是相对安装包的,例如/assets/... dexLoader | ["com.tencent.tinker.loader.*"] | 这一项非常重要,它定义了哪些类在加载补丁包的时候会用到。这些类是通过Tinker无法修改的类,也是一定要放在main dex的类。 这里需要定义的类有: 1. 你自己定义的Application类; 2. Tinker库中用于加载补丁包的部分类,即com.tencent.tinker.loader.*; 3. 如果你自定义了TinkerLoader,需要将它以及它引用的所有类也加入loader中; 4. 其他一些你不希望被更改的类,例如Sample中的BaseBuildInfo类。**这里需要注意的是,这些类的直接引用类也需要加入到loader中。或者你需要将这个类变成非preverify。** libPattern | ["lib/armeabi/*.so"] | 需要处理lib路径,支持*、?通配符,必须使用'/'分割。与dex.pattern一致, 路径是相对安装包的,例如/assets/... resPattern | ["res/_ ", "assets/_ ", "resources.arsc", "AndroidManifest.xml"] | 需要处理res路径,支持*、?通配符,必须使用'/'分割。与dex.pattern一致, 路径是相对安装包的,例如/assets/...,**务必注意的是,只有满足pattern的资源才会放到合成后的资源包** 。 resIgnoreChange | ["assets/*_meta.txt"] | 支持*、?通配符,必须使用'/'分割。若满足ignoreChange的pattern,在编译时会忽略该文件的新增、删除与修改。 **最极端的情况,ignoreChange与上面的pattern一致,即会完全忽略所有资源的修改。** resLargeModSize | 100 | 对于修改的资源,如果大于largeModSize,我们将使用bsdiff算法。这可以降低补丁包的大小,但是会增加合成时的复杂度。默认大小为100kb configField | TINKER_ID, NEW_TINKER_ID | configField("key", "value"), 默认我们自动从基准安装包与新安装包的Manifest中读取tinkerId,并自动写入configField。在这里,你可以定义其他的信息,在运行时可以通过TinkerLoadResult.getPackageConfigByName得到相应的数值。但是建议直接通过修改代码来实现,例如BuildConfig。 sevenZipArtifact | "com.tencent.mm:SevenZip:1.1.10" | 例如"com.tencent.mm:SevenZip:1.1.10",将自动根据机器属性获得对应的7za运行文件,推荐使用。 sevenZipExecutePath | "/usr/local/bin/7za" | 系统中的7za路径,例如"/usr/local/bin/7za"。path设置会覆盖zipArtifact,若都不设置,将直接使用7za去尝试。 isProtectedApp | false | 是否使用加固模式,仅仅将变更的类合成补丁。注意,这种模式仅仅可以用于加固应用中。 enableProxyApplication | false | 是否使用proxy/delegate application 模式 ``` -------------------------------- ### Swift 初始化 Bugly SDK Source: https://bugly.qq.com/docs/user-guide/instruction-manual-ios_v=1.0 在Swift项目中,通过调用Bugly的startWithAppId方法来初始化SDK。此方法应在application(_:didFinishLaunchingWithOptions:)方法中执行,并传入你的AppId。 ```Swift func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { Bugly.startWithAppId("此处替换为你的AppId") return true } ``` -------------------------------- ### Example of Automatic Javascript Exception Monitoring (Java) Source: https://bugly.qq.com/docs/user-guide/advance-features-android_v=1.0 This Java example demonstrates the complete setup for automatic Javascript exception monitoring. It involves creating a WebView, setting a `WebChromeClient` to call `CrashReport.setJavascriptMonitor` in `onProgressChanged`, and then loading a URL. ```Java WebView webView = new WebView(this); // 设置WebChromeClient webView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView webView, int progress) { // 增加Javascript异常监控 CrashReport.setJavascriptMonitor(webView, true); super.onProgressChanged(webView, progress); } }); // 加载HTML webView.loadUrl(url); ``` -------------------------------- ### Example of Automatic Javascript Exception Monitoring (Java) Source: https://bugly.qq.com/docs/user-guide/advance-features-android This Java example demonstrates the complete setup for automatic Javascript exception monitoring. It involves creating a WebView, setting a `WebChromeClient` to call `CrashReport.setJavascriptMonitor` in `onProgressChanged`, and then loading a URL. ```Java WebView webView = new WebView(this); // 设置WebChromeClient webView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView webView, int progress) { // 增加Javascript异常监控 CrashReport.setJavascriptMonitor(webView, true); super.onProgressChanged(webView, progress); } }); // 加载HTML webView.loadUrl(url); ``` -------------------------------- ### CocoaPods 集成 Bugly SDK Source: https://bugly.qq.com/docs/user-guide/instruction-manual-ios_v=1.0 通过CocoaPods集成Bugly SDK到iOS项目中。需要在Podfile中添加'Bugly'依赖,然后执行'pod install'命令。如果版本不是最新的,需要先更新本地repo。 ```Ruby pod 'Bugly' ``` -------------------------------- ### Objective-C 初始化 Bugly SDK Source: https://bugly.qq.com/docs/user-guide/instruction-manual-ios_v=1.0 在Objective-C项目中,通过调用Bugly的startWithAppId方法来初始化SDK。此方法应在application:didFinishLaunchingWithOptions:方法中执行,并传入你的AppId。 ```Objective-C - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [Bugly startWithAppId:@"此处替换为你的AppId"]; return YES; } ``` -------------------------------- ### Manual Javascript Exception Monitoring Setup (Java) Source: https://bugly.qq.com/docs/user-guide/advance-features-android_v=1.0 This Java code demonstrates the manual setup for Javascript exception monitoring. After loading an HTML file that includes `bugly.js`, you call `CrashReport.setJavascriptMonitor(webView, false)` to enable the monitoring. ```Java WebView webView = new WebView(this); // 加载HTML webView.loadUrl(url); // 增加Javascript异常监控 CrashReport.setJavascriptMonitor(webView, false); ``` -------------------------------- ### Manual Javascript Exception Monitoring Setup (Java) Source: https://bugly.qq.com/docs/user-guide/advance-features-android This Java code demonstrates the manual setup for Javascript exception monitoring. After loading an HTML file that includes `bugly.js`, you call `CrashReport.setJavascriptMonitor(webView, false)` to enable the monitoring. ```Java WebView webView = new WebView(this); // 加载HTML webView.loadUrl(url); // 增加Javascript异常监控 CrashReport.setJavascriptMonitor(webView, false); ``` -------------------------------- ### CocoaPods 集成 Bugly SDK Source: https://bugly.qq.com/docs/user-guide/instruction-manual-ios 通过CocoaPods集成Bugly SDK到iOS项目中。需要在Podfile中添加'Bugly'依赖,然后执行'pod install'命令。如果版本不是最新的,需要先更新本地repo。 ```Ruby pod 'Bugly' ``` -------------------------------- ### Objective-C 初始化 Bugly SDK Source: https://bugly.qq.com/docs/user-guide/instruction-manual-ios 在Objective-C项目中,通过调用Bugly的startWithAppId方法来初始化SDK。此方法应在application:didFinishLaunchingWithOptions:方法中执行,并传入你的AppId。 ```Objective-C - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [Bugly startWithAppId:@"此处替换为你的AppId"]; return YES; } ``` -------------------------------- ### Implement WebViewInterface for Non-Standard WebViews (Java) Source: https://bugly.qq.com/docs/user-guide/advance-features-android_v=1.0 This Java code demonstrates how to implement the `CrashReport.WebViewInterface` for non-standard WebViews (e.g., those using X5 kernel). It provides methods to get the WebView URL, enable/disable Javascript, load URLs, add Javascript interfaces, and get content descriptions. This requires Bugly Android SDK version 2.5.0 or higher. ```Java CrashReport.WebViewInterface webView = new CrashReport.WebViewInterface() { /** * 获取WebView URL. * * @return WebView URL */ @Override public String getUrl() { // 下面仅为例子,请用真正逻辑代替 return <第三方WebView对象>.getUrl(); } /** * 开启JavaScript. * @param flag true表示开启,false表示关闭 */ @Override public void setJavaScriptEnabled(boolean flag) { // 下面仅为例子,请用真正逻辑代替 WebSettings webSettings = <第三方WebView对象>.getSettings(); webSettings.setJavaScriptEnabled(flag); } /** * 加载URL. * @param url 要加载的URL */ @Override public void loadUrl(String url) { // 下面仅为例子,请用真正逻辑代替 <第三方WebView对象>.loadUrl(); } /** * 添加JavaScript接口对象. * @param jsInterface JavaScript接口对象 * @param name JavaScript接口对象名称 */ @Override public void addJavascriptInterface(H5JavaScriptInterface jsInterface, String name) { // 下面仅为例子,请用真正逻辑代替 <第三方WebView对象>.addJavascriptInterface(jsInterface, name); } /** * 获取WebView的内容描述. * @return WebView的内容描述. */ @Override public CharSequence getContentDescription() { // 下面仅为例子,请用真正逻辑代替 return <第三方WebView对象>.getContentDescription(); } }; // 调用Bugly设置JS异常捕获接口时传入创建的WebView接口对象即可 ``` -------------------------------- ### Implement WebViewInterface for Non-Standard WebViews (Java) Source: https://bugly.qq.com/docs/user-guide/advance-features-android This Java code demonstrates how to implement the `CrashReport.WebViewInterface` for non-standard WebViews (e.g., those using X5 kernel). It provides methods to get the WebView URL, enable/disable Javascript, load URLs, add Javascript interfaces, and get content descriptions. This requires Bugly Android SDK version 2.5.0 or higher. ```Java CrashReport.WebViewInterface webView = new CrashReport.WebViewInterface() { /** * 获取WebView URL. * * @return WebView URL */ @Override public String getUrl() { // 下面仅为例子,请用真正逻辑代替 return <第三方WebView对象>.getUrl(); } /** * 开启JavaScript. * @param flag true表示开启,false表示关闭 */ @Override public void setJavaScriptEnabled(boolean flag) { // 下面仅为例子,请用真正逻辑代替 WebSettings webSettings = <第三方WebView对象>.getSettings(); webSettings.setJavaScriptEnabled(flag); } /** * 加载URL. * @param url 要加载的URL */ @Override public void loadUrl(String url) { // 下面仅为例子,请用真正逻辑代替 <第三方WebView对象>.loadUrl(); } /** * 添加JavaScript接口对象. * @param jsInterface JavaScript接口对象 * @param name JavaScript接口对象名称 */ @Override public void addJavascriptInterface(H5JavaScriptInterface jsInterface, String name) { // 下面仅为例子,请用真正逻辑代替 <第三方WebView对象>.addJavascriptInterface(jsInterface, name); } /** * 获取WebView的内容描述. * @return WebView的内容描述. */ @Override public CharSequence getContentDescription() { // 下面仅为例子,请用真正逻辑代替 return <第三方WebView对象>.getContentDescription(); } }; // 调用Bugly设置JS异常捕获接口时传入创建的WebView接口对象即可 ``` -------------------------------- ### Swift 初始化 Bugly SDK Source: https://bugly.qq.com/docs/user-guide/instruction-manual-ios 在Swift项目中,通过调用Bugly的startWithAppId方法来初始化SDK。此方法应在application(_:didFinishLaunchingWithOptions:)方法中执行,并传入你的AppId。 ```Swift func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { Bugly.startWithAppId("此处替换为你的AppId") return true } ``` -------------------------------- ### Android SDK: Add Get SDK Version Interface and App Foreground/Background Setting Source: https://bugly.qq.com/docs/release-notes/release-android-bugly_v=1.0 Version 1.2.9 adds an interface to get the Bugly SDK version number and an interface to set the app's foreground/background status. It also fixes an issue where the disable crash monitoring interface might become invalid. This is an internal SDK update. ```Java /* * Add interface to get Bugly SDK version number. */ // Example: String version = Bugly.getSDKVersion(); /* * Add interface to set app foreground/background status. */ // Example: Bugly.setAppForeground(true); // or false ``` -------------------------------- ### 集成Bugly SDK (Gradle) Source: https://bugly.qq.com/docs/user-guide/instruction-manual-android_v=1.0 在Android项目的build.gradle文件中添加Bugly SDK的依赖,并配置NDK的ABI过滤器以支持特定的SO库架构。此配置推荐用于自动集成方式。 ```Gradle android { defaultConfig { ndk { // 设置支持的SO库架构 abiFilters 'armeabi' //, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a' } } } dependencies { implementation 'com.tencent.bugly:crashreport:latest.release' //其中latest.release指代最新Bugly SDK版本号,也可以指定明确的版本号,例如4.0.3 } ``` -------------------------------- ### 配置SO库架构 Source: https://bugly.qq.com/docs/user-guide/faq-android_v=1.0 在build.gradle文件中配置ndk支持的SO库架构,以解决在虚拟机或特定设备上安装时提示不支持x86架构的问题。 ```Gradle ndk { //设置支持的SO库架构 abiFilters 'armeabi', 'x86' } ``` -------------------------------- ### Android SDK: Add Get SDK Version Interface and App Foreground/Background Setting Source: https://bugly.qq.com/docs/release-notes/release-android-bugly Version 1.2.9 adds an interface to get the Bugly SDK version number and an interface to set the app's foreground/background status. It also fixes an issue where the disable crash monitoring interface might become invalid. This is an internal SDK update. ```Java /* * Add interface to get Bugly SDK version number. */ // Example: String version = Bugly.getSDKVersion(); /* * Add interface to set app foreground/background status. */ // Example: Bugly.setAppForeground(true); // or false ``` -------------------------------- ### 手动集成Bugly SDK (Gradle) Source: https://bugly.qq.com/docs/user-guide/instruction-manual-android_v=1.0 当采用手动集成方式时,将下载的Bugly aar文件复制到libs目录,并在module的gradle文件中添加对该aar文件的依赖。 ```Gradle dependencies { implementation files('libs/Bugly_sdk.aar') } ``` -------------------------------- ### Symbol Table Tool Version 2.6.3 Improvements Source: https://bugly.qq.com/docs/release-notes/release-symboltool_v=1.0 Version 2.6.3 resolves an issue with packaging failures when input SO files have the same name and architecture. It also optimizes tool prompts, the debug mode, and the usage guide. ```Java /* * Version 2.6.3 (2016-08-15) * Fixes packaging failure when input contains SO files with the same name and architecture. * Optimizes tool prompts and debug mode. * Optimizes the usage guide. */ ``` -------------------------------- ### iOS SDK 更新日志 - Bugly Source: https://bugly.qq.com/docs/release-notes/release-ios-bugly 此部分内容为 Bugly iOS SDK 的更新日志,记录了从 1.2.9 到 2.6.1 各个版本的更新内容。主要包括适配苹果隐私清单、解决 IDFV 多次获取问题、处理内存泄露、新增关闭 Bugly 监听接口、修复崩溃回调函数问题、处理 arm64 位 PAC 问题、修复 App 崩溃后上报卡死问题、添加 modulemap 文件兼容 Swift 工程、修复热更新 SDK 切换崩溃、修复符号冲突问题、添加页面跟踪时间信息、区分 C++ 异常类型上报、新增控制台日志上报、新增内存信息上报、修复初始化调用失败问题、修复数据积压上报崩溃问题、添加堆栈过滤上报配置接口、优化崩溃数据上报逻辑、修复缓存文件删除失败问题、修复 iOS 10 兼容性问题、兼容 IPv6、修复堆栈乱码问题、修复进程内符号化崩溃问题、优化崩溃回调函数兼容性、新增自定义异常上报接口、修复卡顿功能偶现崩溃问题、修复页面追踪功能与 Aspects 冲突问题、修复 WCSession 通讯失败问题、代码重构性能提升、数据传输采用更高级别安全策略、去除 C++ 依赖库、新增从 Info.plist 读取配置参数、修复部分信息为空值问题、修复远程策略关闭时 SDK 注册监听问题、添加界面追踪功能、优化非正常退出事件上报逻辑、修复 iOS 8 网络百分百 loss 死锁问题、调整第三方 SDK 兼容性处理、修复崩溃数据上报二次崩溃问题、新增意外退出场景事件上报、优化卡顿监控及上报、优化第三方 SDK 兼容性处理、支持 JavaScript 异常上报、支持 watchOS 2 异常上报、修复 iOS 8 DNS 受污染引起的问题、修复线程安全问题、数据存储性能优化、添加运营统计数据、数据实时上报稳定性提升及性能优化、修复自定义日志上报线程安全问题、性能优化、新增自定义日志功能、自定义异常上报添加 Tag 上报、全面适配 iOS 9 支持 Bitcode、支持 App Transport Security、修复 iOS 8 以下系统兼容性问题、支持 Extension 异常上报、优化网络处理。 ```Objective-C /* * TencentBugly.h * TencentBugly * * Created by Tencent on 15/11/4. * Copyright © 2015年 Tencent. All rights reserved. */ #import // 异常上报 // 1. 基础异常捕获 // 2. 自定义异常捕获 // 3. JavaScript 异常捕获 // 4. C++ 异常捕获 // 运营统计 // 1. 页面跟踪 // 2. 自定义事件统计 // 应用升级 // 1. 热更新 // 其他 // 1. 自定义日志 // 2. 内存泄漏检测 // 3. 卡顿检测 // 4. 线程安全 // 5. 兼容性处理 (Swift, Cocos, Unity, watchOS) // 6. 隐私清单适配 // 7. App Transport Security 支持 // 8. Bitcode 支持 // 9. IPv6 支持 // 10. 安全策略升级 // 11. Modulemap 文件支持 // 接口示例: // [Bugly startWithAppId:@"YOUR_APP_ID"]; // 初始化 // [Bugly setUserIdentifier:@"user_id"]; // 设置用户标识 // [Bugly reportException:exception]; // 上报自定义异常 // [Bugly uploadLogData]; // 上报日志数据 // [Bugly updateAppVersion:@"1.0.0"]; // 更新App版本 // [Bugly setTagValue:@"tag_value" forKey:@"tag_key"]; // 设置自定义标签 // [Bugly closeBugly]; // 关闭Bugly监听 ``` -------------------------------- ### Android SDK: Merge JAR and SO to AAR Release Source: https://bugly.qq.com/docs/release-notes/release-android-bugly Version 4.0.4 announces the release of the SDK in AAR format, merging JAR and SO files for easier integration. Users should refer to the Android SDK Usage Guide for integration instructions. ```Java /* * Android SDK Usage Guide - Integrate SDK * Refer to: Android SDK Usage Guide - Integrate SDK */ // Integration instructions will be provided in the SDK documentation. ``` -------------------------------- ### 集成Bugly SDK (Gradle) Source: https://bugly.qq.com/docs/user-guide/instruction-manual-android 在Android项目的build.gradle文件中添加Bugly SDK的依赖,并配置NDK的ABI过滤器以支持特定的SO库架构。此配置推荐用于自动集成方式。 ```Gradle android { defaultConfig { ndk { // 设置支持的SO库架构 abiFilters 'armeabi' //, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a' } } } dependencies { implementation 'com.tencent.bugly:crashreport:latest.release' //其中latest.release指代最新Bugly SDK版本号,也可以指定明确的版本号,例如4.0.3 } ``` -------------------------------- ### Android SDK: Merge JAR and SO to AAR Release Source: https://bugly.qq.com/docs/release-notes/release-android-bugly_v=1.0 Version 4.0.4 announces the release of the SDK in AAR format, merging JAR and SO files for easier integration. Users should refer to the Android SDK Usage Guide for integration instructions. ```Java /* * Android SDK Usage Guide - Integrate SDK * Refer to: Android SDK Usage Guide - Integrate SDK */ // Integration instructions will be provided in the SDK documentation. ``` -------------------------------- ### 降低Gradle版本 Source: https://bugly.qq.com/docs/user-guide/faq-android_v=1.0 当Gradle编译缓慢或卡在依赖解析时,可以尝试修改根目录build.gradle文件中的classpath依赖,使用较低版本的Gradle来解决。 ```Gradle dependencies { classpath 'com.android.tools.build:gradle:1.5.0' } ``` -------------------------------- ### Get Process Name for Bugly QQ Upload Control Source: https://bugly.qq.com/docs/user-guide/advance-features-android_v=1.0 A utility method to retrieve the process name associated with a given process ID (PID). This is used to determine if the current process is the main application process for controlling Bugly QQ data uploads. ```Java /** * 获取进程号对应的进程名 * * @param pid 进程号 * @return 进程名 */ private static String getProcessName(int pid) { BufferedReader reader = null; try { reader = new BufferedReader(new FileReader("/proc/" + pid + "/cmdline")); String processName = reader.readLine(); if (!TextUtils.isEmpty(processName)) { processName = processName.trim(); } return processName; } catch (Throwable throwable) { throwable.printStackTrace(); } finally { try { if (reader != null) { reader.close(); } } catch (IOException exception) { exception.printStackTrace(); } } return null; } ``` -------------------------------- ### 手动集成Bugly SDK (Gradle) Source: https://bugly.qq.com/docs/user-guide/instruction-manual-android 当采用手动集成方式时,将下载的Bugly aar文件复制到libs目录,并在module的gradle文件中添加对该aar文件的依赖。 ```Gradle dependencies { implementation files('libs/Bugly_sdk.aar') } ``` -------------------------------- ### Get Process Name for Bugly QQ Upload Control Source: https://bugly.qq.com/docs/user-guide/advance-features-android A utility method to retrieve the process name associated with a given process ID (PID). This is used to determine if the current process is the main application process for controlling Bugly QQ data uploads. ```Java /** * 获取进程号对应的进程名 * * @param pid 进程号 * @return 进程名 */ private static String getProcessName(int pid) { BufferedReader reader = null; try { reader = new BufferedReader(new FileReader("/proc/" + pid + "/cmdline")); String processName = reader.readLine(); if (!TextUtils.isEmpty(processName)) { processName = processName.trim(); } return processName; } catch (Throwable throwable) { throwable.printStackTrace(); } finally { try { if (reader != null) { reader.close(); } } catch (IOException exception) { exception.printStackTrace(); } } return null; } ``` -------------------------------- ### Symbol Table Tool Version 2.3.0 Directory and GNU Build-ID Support Source: https://bugly.qq.com/docs/release-notes/release-symboltool_v=1.0 Version 2.3.0 enhances directory searching to process multiple SO files, allows specifying the output directory, and supports parsing GNU Build-ID. The usage guide has also been optimized. ```Java /* * Version 2.3.0 (2015-11-03) * Supports searching input directories for multiple SO files. * Supports specifying the output as a directory. * Supports parsing GNU Build-ID. * Optimizes the usage guide. */ ``` -------------------------------- ### 添加网络权限 (AndroidManifest.xml) Source: https://bugly.qq.com/docs/user-guide/instruction-manual-android_v=1.0 在AndroidManifest.xml文件中添加必要的网络权限,包括访问互联网、网络状态和Wi-Fi状态,以确保Bugly SDK能够正常工作。 ```XML ``` -------------------------------- ### Android SDK: Privacy Information Acquisition Update and Device ID/Model Settings Source: https://bugly.qq.com/docs/release-notes/release-android-bugly Version 3.4.4 updates privacy information acquisition by replacing 'androidId' with a GUID and recommends using a host app's unique identifier. It also adds a method to set the 'deviceModel' and defaults 'webview.setAllowFileAccess' to false. ```Java /* * Advanced Features - Set Device ID * Recommend using your own unique identifier. */ // Example: bugly.setUserId("YourUniqueAppId"); /* * Advanced Features - Set Device Model * Recommend setting the device model. */ // Example: bugly.setDeviceModel("YourDeviceModel"); /* * Set webview setAllowFileAccess to false by default. */ // No direct code example, this is an internal SDK change. ``` -------------------------------- ### 添加网络权限 (AndroidManifest.xml) Source: https://bugly.qq.com/docs/user-guide/instruction-manual-android 在AndroidManifest.xml文件中添加必要的网络权限,包括访问互联网、网络状态和Wi-Fi状态,以确保Bugly SDK能够正常工作。 ```XML ``` -------------------------------- ### 初始化 Bugly Unity Plugin Source: https://bugly.qq.com/docs/user-guide/instruction-manual-plugin-unity_v=1.0 在Unity项目的C#脚本中初始化Bugly SDK,并启用异常捕获功能。支持iOS和Android平台。 ```csharp // 开启SDK的日志打印,发布版本请务必关闭 BuglyAgent.ConfigDebugMode (true); // 注册日志回调,替换使用 'Application.RegisterLogCallback(Application.LogCallback)'注册日志回调的方式 // BuglyAgent.RegisterLogCallback (CallbackDelegate.Instance.OnApplicationLogCallbackHandler); #if UNITY_IPHONE || UNITY_IOS BuglyAgent.InitWithAppId ("Your App ID"); #elif UNITY_ANDROID BuglyAgent.InitWithAppId ("Your App ID"); #endif // 如果你确认已在对应的iOS工程或Android工程中初始化SDK,那么在脚本中只需启动C#异常捕获上报功能即可 BuglyAgent.EnableExceptionHandler (); ``` -------------------------------- ### Android SDK: Privacy Information Acquisition Update and Device ID/Model Settings Source: https://bugly.qq.com/docs/release-notes/release-android-bugly_v=1.0 Version 3.4.4 updates privacy information acquisition by replacing 'androidId' with a GUID and recommends using a host app's unique identifier. It also adds a method to set the 'deviceModel' and defaults 'webview.setAllowFileAccess' to false. ```Java /* * Advanced Features - Set Device ID * Recommend using your own unique identifier. */ // Example: bugly.setUserId("YourUniqueAppId"); /* * Advanced Features - Set Device Model * Recommend setting the device model. */ // Example: bugly.setDeviceModel("YourDeviceModel"); /* * Set webview setAllowFileAccess to false by default. */ // No direct code example, this is an internal SDK change. ``` -------------------------------- ### Bugly iOS SDK 升级指南:初始化接口变更 Source: https://bugly.qq.com/docs/user-guide/upgrading-2_v=1.0 展示了 Bugly iOS SDK 初始化接口从 1.x 到 2.x 的变更,包括导入头文件和初始化SDK的方法。 ```Objective-C #import ``` ```Objective-C #import ``` ```Objective-C [[CrashReporter sharedInstance] installWithAppkey:@"BUGLY_APP_ID"]; ``` ```Objective-C [Bugly startWithAppId:@"BUGLY_APP_ID"]; ``` ```Objective-C [[CrashReporter sharedInstance] installWithAppkey:@"BUGLY_APP_ID" applicationGroupIdentifier:@"APP_GROUP_ID"]; ``` ```Objective-C BuglyConfig *config = [[BuglyConfig alloc] init]; config.applicationGroupIdentifier = @"APP_GROUP_ID"; [Bugly startWithAppId:@"BUGLY_APP_ID" config:config]; ``` -------------------------------- ### Bugly TAG Crash Statistics Webhook Payload Source: https://bugly.qq.com/docs/user-guide/webhook-bugly_v=1.0 This JSON payload details the structure for TAG crash statistics sent by Bugly. It includes crash counts and affected users for specific tags, along with tag IDs and names. The payload also contains a URL for detailed search results in Bugly and app-level information. ```json { "eventType": "bugly_tag", "timestamp": 1462780713515, "isEncrypt": 0, "eventContent": { "datas": [ { "tagId": 12972, "tagName": "testTag2", "crashCount": 21, "crashUser": 20, "type": 2, "url": "http://bugly.qq.com/search?app=1104512706&pid=1&ptag=1017-10000&ver=all&bi=all&cl=all&ct=all&s=all&dt=all&tl=12972" }, { "tagId": 15019, "tagName": "testTag1", "crashCount": 66, "crashUser": 64, "type": 2, "url": "http://bugly.qq.com/search?app=1104512706&pid=1&ptag=1017-10000&ver=all&bi=all&cl=all&ct=all&s=all&dt=all&tl=12972" }, { "tagId": 15120, "tagName": "testTag", "crashCount": 1430, "crashUser": 1423, "type": 2, "url": "http://bugly.qq.com/search?app=1104512706&pid=1&ptag=1017-10000&ver=all&bi=all&cl=all&ct=all&s=all&dt=all&tl=12972" } ], "appId": "1104512706", "platformId": 1, "appName": "AF", "date": "20160508", "appUrl":"http://bugly.qq.com/issueIndex?app=1104512706&pid=1&ptag=1005-10000" }, "signature": "ACE346A4AE13A23A52A0D0D19350B466AF51728A" } ``` -------------------------------- ### Symbol Table Tool Version 2.1.2 Symbol Table Accuracy Source: https://bugly.qq.com/docs/release-notes/release-symboltool_v=1.0 Version 2.1.2 improves the accuracy of symbol tables, fixes occasional missing symbols, and adds shell (Linux) and BAT (Windows) scripts. It also includes a symbol table usage guide and optimizes the symbol table file format. ```Java /* * Version 2.1.2 (2015-07-14) * Improves symbol table accuracy. * Fixes occasional missing symbols. * Adds shell scripts (Linux) and bat scripts (Windows). * Adds symbol table usage guide. * Optimizes symbol table file format. */ ``` -------------------------------- ### 初始化 Bugly SDK (C++) Source: https://bugly.qq.com/docs/user-guide/instruction-manual-plugin-cocos_v=1.0 在AppDelegate.cpp文件的applicationDidFinishLaunching方法中调用CrashReport::initCrashReport接口来初始化Bugly SDK,需要传入AppID和调试模式标志。 ```cpp #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "bugly/CrashReport.h" #elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #include "CrashReport.h" #endif ``` ```cpp bool AppDelegate::applicationDidFinishLaunching() { // Init the Bugly CrashReport::initCrashReport("Your AppID", false); // initialize director auto director = Director::getInstance(); // ... return true; } ``` -------------------------------- ### 配置Proguard混淆规则 Source: https://bugly.qq.com/docs/user-guide/instruction-manual-android_v=1.0 为了防止Bugly SDK的代码被混淆,需要在Proguard混淆配置文件中添加相应的规则,包括不警告和保持Bugly类及其成员。 ```Proguard -dontwarn com.tencent.bugly.** -keep public class com.tencent.bugly.**{*;} ``` -------------------------------- ### 初始化其他类型 Extension SDK (Swift) Source: https://bugly.qq.com/docs/user-guide/instruction-manual-ios-app-extension 为 Today Extension、Share Extension 等其他类型的 iOS Extension 初始化 Bugly Extension SDK。需要在 `init(coder:)` 方法中调用 `CrashReporterLite.startWithApplicationGroupIdentifier:`。 ```Swift required init(coder aDecoder: NSCoder) { CrashReporterLite.startWithApplicationGroupIdentifier("此处替换为您的 App Group Identifier") super.init(coder: aDecoder) } ``` -------------------------------- ### Bugly Daily Crash Statistics Webhook Payload Source: https://bugly.qq.com/docs/user-guide/webhook-bugly_v=1.0 This JSON payload represents the data structure for daily crash statistics sent by Bugly via webhook. It includes information about connected users, crash counts, affected users, app versions, and a URL to the Bugly report. The payload also contains app-level details like appId, platformId, appName, and date. ```json { "eventType": "bugly_crash_trend", "timestamp": 1462780713515, "isEncrypt": 0, "eventContent": { "datas": [ { "accessUser": 12972, "crashCount": 21, "crashUser": 20, "version": "1.2.3", "url": "http://bugly.qq.com/realtime?app=1104512706&pid=1&ptag=1005-10003&vers=0.0.0.12.12&time=last_7_day&tab=crash" }, { "accessUser": 15019, "crashCount": 66, "crashUser": 64, "version": "1.2.4", "url": "http://bugly.qq.com/realtime?app=1104512706&pid=1&ptag=1005-10003&vers=0.0.0.12.12&time=last_7_day&tab=crash" }, { "accessUser": 15120, "crashCount": 1430, "crashUser": 1423, "version": "1.2.4", "url": "http://bugly.qq.com/realtime?app=1104512706&pid=1&ptag=1005-10003&vers=0.0.0.12.12&time=last_7_day&tab=crash" } ], "appId": "1104512706", "platformId": 1, "appName": "AF", "date": "20160508", "appUrl":"http://bugly.qq.com/issueIndex?app=1104512706&pid=1&ptag=1005-10000" }, "signature": "ACE346A4AE13A23A52A0D0D19350B466AF51728A" } ``` -------------------------------- ### 初始化 Bugly watchOS SDK (Swift) Source: https://bugly.qq.com/docs/user-guide/instruction-manual-watchos_v=1.0 此代码段展示了如何在 Swift 工程中初始化 Bugly watchOS SDK。它使用应用程序组标识符启动 SDK。 ```Swift override init() { CrashReporterLite.startWithApplicationGroupIdentifier("此处替换为您的 App Group Identifier") super.init() } ```