Android-SDK

<p><strong>SDK</strong><strong>之Android Studio(Gradle</strong><strong>2.*</strong><strong>)</strong><strong>使用说明</strong></p> <p><a href="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/%E6%9C%AC%E5%9C%B0%E9%9B%86%E6%88%90V2.2.2.14.zip?response-content-disposition=attachment%3Bfilename%3D%25E6%259C%25AC%25E5%259C%25B0%25E9%259B%2586%25E6%2588%2590V2.2.2.14.zip"><span style="color:#3076da">下载AndroidSDK V2.2.2.14</span></a></p> <p>使用须知:</p> <p>Android SDK优先支持Android 2.*以上8.*以下的Android系统,此次版本为Gradle(2.*)构建方式。</p> <p><strong>即项目根目录下的build.gradle中使用的</strong><strong>classpath </strong><strong>&#39;com.android.tools.build:gradle:2.*.*&#39;</strong></p> <p>IDE:Android Studio</p> <p>PartA:性能数据监测</p> <p><strong>一、预置SDK环境</strong></p> <p><strong>解压bonree_sdk_android_gradle.zip得到bonree_sdk_android_gradle文件夹,暂存本地(如E:\);</strong></p> <p>1.1拷贝license.dat或者BonreeSDKLicense.dat文件到App项目的app\src\main\assets目录下(如果项目中没有assets目录,请创建assets目录);</p> <p>1.2拷贝jniLib覆盖App项目主模块的jniLibs目录(如果项目中没有jniLibs目录,请创建jniLibs目录);</p> <p>1.3 拷贝repo文件夹到App项目根目录;</p> <p>1.4 拷贝com.bonree.agent.jar到App项目主模块的libs目录;</p> <p>&nbsp;</p> <p><strong>注意:Mac下,bonree_sdk_android_gradle文件夹的路径最好放在/Users/xxxx/目录下,放在系统目录下,由于权限可能导致一些难以预计的问题</strong></p> <p><strong>二、配置Gradle</strong></p> <p><strong>1.</strong><strong>打开工程根目录下的build.gradle文件</strong></p> <p><strong>2.</strong><strong>在</strong><strong>build.gradle</strong><strong>文件</strong><strong>中加入代码</strong></p> <p>在repositories模块中加入脚本</p> <pre> maven {</pre> <pre> &nbsp;&nbsp;&nbsp; url uri(&#39;./repo&#39;)</pre> <pre> }</pre> <p>在dependencies模块中加入脚本(2.1.6.6为bonree插件版本号,请每次使用最新版本号,本次插件最新2.2.1.8)</p> <pre> classpath &#39;com.bonree.agent.android:bonree:2.2.1.8&#39;</pre> <pre> 如下图1-1:</pre> <p><strong>其中</strong><strong>./repo</strong><strong>请替换为您本地</strong><strong>repo</strong><strong>所在路径</strong></p> <p>&nbsp;<img src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20182205180127-1f0d91b29ffe.png" style="height:311px; width:548px" /></p> <p><strong>三、引入SDK</strong></p> <p><strong>1.</strong><strong>打开主模块目录下的build.gradle文件</strong></p> <p><strong>2.</strong><strong>在dependencies模块中加入代码</strong></p> <pre> compile fileTree(dir: &#39;libs&#39;, include: [&#39;*.jar&#39;])</pre> <p><strong>注意:E:\\bonree_sdk_android_gradle请替换为您本地bonree_sdk_android_gradle所在路径</strong></p> <p><strong>3.</strong><strong>在文件头部引入Bonree插件</strong></p> <pre> apply plugin: <strong>&#39;bonree&#39;</strong></pre> <p><img src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20182205180554-1892685a905b.png" style="height:369px; width:553px" /></p> <p><strong>四、Rebuid &amp; Clean项目</strong></p> <p><strong>Rebuild &amp; Clean</strong><strong>项目,确保SDK配置生效。</strong></p> <p><img src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20182205180609-1ec1b7069b20.png" style="height:239px; width:261px" /></p> <p><strong>五、配置授权信息</strong></p> <p><strong>检查应用程序AndroidManifest.xml配置文件,确保已引入如下授权:</strong></p> <pre> &lt;<strong>uses-permission </strong><strong>android</strong><strong>:name=</strong><strong>&quot;android.permission.INTERNET&quot;</strong>/&gt; &lt;<strong>uses-permission </strong><strong>android</strong><strong>:name=</strong><strong>&quot;android.permission.ACCESS_NETWORK_STATE&quot;</strong>/&gt; &lt;<strong>uses-permission </strong><strong>android</strong><strong>:name=</strong><strong>&quot;android.permission.READ_PHONE_STATE&quot;</strong>/&gt; &lt;<strong>uses-permission </strong><strong>android</strong><strong>:name=</strong><strong>&quot;android.permission.GET_TASKS&quot;</strong>/&gt; &lt;<strong>uses-permission </strong><strong>android</strong><strong>:name=</strong><strong>&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;</strong>/&gt; &lt;<strong>uses-permission </strong><strong>android</strong><strong>:name=</strong><strong>&quot;android.permission.READ_EXTERNAL_STORAGE&quot;</strong>/&gt;</pre> <pre> &lt;<strong>uses-permission </strong><strong>android</strong><strong>:name=</strong><strong>&quot;android.permission.READ_LOGS&quot;</strong>/&gt;</pre> <p><strong>若您的应用使用proguard混淆,请配置如下:</strong></p> <p># ProGuard configurations for Bonree-Agent</p> <p>&nbsp;&nbsp;&nbsp;&nbsp; -keep public class com.bonree.**{*;}</p> <p>&nbsp;&nbsp;&nbsp;&nbsp; -keep public class bonree.**{*;}</p> <p>&nbsp;&nbsp;&nbsp;&nbsp; -dontwarn com.bonree.**</p> <p>&nbsp;&nbsp;&nbsp;&nbsp; -dontwarn bonree.**</p> <p># End Bonree-Agent</p> <p><strong>六、启动Agent</strong></p> <p>在待监测App的主Activity(MainActivity)源文件中导入博睿App的Android探针类:</p> <p>&nbsp; import com.bonree.agent.android.Bonree;</p> <p><strong>初始化Agent:</strong></p> <p><strong>情况1:</strong>请在入口Activity的onCreate()方法的第一行增加如下代码:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Bonree.withApplicationToken(&quot;b26b0566-cdda-4bb6-8e09-45fa33ffeac1&quot;).start(this);</p> <p><strong>情况</strong><strong>2</strong>:若不需要采集崩溃信息,请在入口Activity的onCreate()方法的第一行增加如下代码:</p> <p>Bonree.withApplicationToken(&quot;b26b0566-cdda-4bb6-8e09-45fa33ffeac1&quot;).withCrashReportingEnabled(false).start(this);</p> <p><strong>情况</strong><strong>3</strong>:设置启动概率:withRateOfLaunch(float rate),参数:0-1.0,默认1.0;如设置启动概率为50%,则传入0.5F,示例:</p> <p>//设置启动概率50%,不采集地理位置,采集崩溃信息</p> <p>Bonree.withApplicationToken(&quot;b26b0566-cdda-4bb6-8e09-45fa33ffeac1&quot;).withRateOfLaunch(0.5F).start(this);</p> <p><strong>情况</strong><strong>4</strong>:设置JS行为数据监测:withJsBridgeEnable(boolean enabled),默认false;如设置开启js行为数据监测,参数设为true,示例:</p> <p>Bonree.withApplicationToken(&quot;b26b0566-cdda-4bb6-8e09-45fa33ffeac1&quot;).withJsBridgeEnable(true).start(this);</p> <p>&nbsp;</p> <p>注意:b26b0566-cdda-4bb6-8e09-45fa33ffeac1为临时字符串,请用应用名称生成的授权编号替换(本次不用替换)</p> <p><strong>七、启动应用程序</strong></p> <p>Clean Project,并重新在模拟器或设备中启动应用程序,开始应用性能管理</p> <p><strong>八、嵌码验证</strong></p> <p>启动已嵌码的apk,查看logcat日志,搜索BRAgent关键字(或者过滤BRSDK-Agent标签),出现如下log则表示嵌码成功</p> <p>&nbsp; BRAgent enable (注:BRAgent 启动成功)</p> <p>&nbsp; BRAgent running(注:BRAgent 集成成功)</p> <p>&nbsp; BRAgent connect server success (注:BRAgent 数据设置成功)</p> <p>&nbsp;</p> <p><strong>PartB:</strong><strong>JAVA接口配置</strong></p> <p><strong>1.</strong><strong>会员id</strong><strong>设置</strong></p> <p>字段说明:</p> <p>id:用户app会员用户的id,主要用于区分不同会员用户的行为。</p> <p>例如:在需要设置会员用户id时,例如id为1,添加如下代码即可:</p> <p>Statistics.onMemberId(&quot;1&quot;);</p> <p>2.<strong>自定义视图的统计</strong></p> <p>字段说明:</p> <p>pageId:自定义视图的ID(只包含英文、数字、下划线和.)。</p> <p>pageName:自定义视图的名称(只包含英文、数字、下划线和.)。</p> <p>在待监测视图类(Activity、Fragment)的</p> <p>onResume方法中调用Statistics.<em>onPageStart</em>(String pageId, String pageName);</p> <p>onPause方法中调用Statistics.<em>onPageEnd</em>(String pageId, String pageName);</p> <p><strong>注:<em>onPageStart</em>和<em>onPageEnd</em>须成对调用。</strong></p> <p>例如:某apk将监测&ldquo;关于&rdquo;界面,其对应视图类About.java</p> <p>代码片段示例如下:</p> <p><img src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20182205180630-19c644a99d28.png" style="height:173px; width:354px" /></p> <p><strong>3.</strong><strong>用户自定义信息的统计</strong></p> <p>字段说明:</p> <p>Kv:自定义信息的Map&lt;String,Object&gt;集合</p> <p>在需要添加自定义信息的模块调用</p> <p>Statistics.setUserInfo(Map&lt;String,Object&gt; kv);</p> <p>例如:某apk在进入某一个页面时设置自定义信息</p> <p>代码片段示例如下:</p> <p><img src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20182205180705-1b9448459790.png" style="height:164px; width:552px" /></p> <p><strong>&nbsp;</strong></p> <p><strong>Part</strong><strong>C</strong><strong>:</strong><strong>JS</strong><strong>接口配置</strong></p> <p><strong>1.</strong><strong>会员id</strong><strong>设置</strong></p> <p>字段说明:</p> <p>id:用户app会员用户的id,主要用于区分不同会员用户的行为。</p> <p>例如:在需要设置会员用户id时,例如id为1,添加如下代码即可:</p> <p>&nbsp;&lt;script&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;function myclick() {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;document.getElementById(&quot;demo&quot;).innerHTML=Date();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;bonreeJsBridge.onMemberId(&#39;1&#39;);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&lt;/script&gt;</p> <p><strong>2.</strong><strong>自定义视图的统计</strong></p> <p>字段说明:</p> <p>pageId:自定义视图的ID(只包含英文、数字、下划线和.)。</p> <p>pageName:自定义视图的名称(只包含英文、数字、下划线和.)。</p> <p>在待监测html页面中的调用</p> <p><em>bonreeJsBridge.onPageStart</em>(String pageId, String pageName);</p> <p><em>bonreeJsBridge.onPageEnd</em>(String pageId, String pageName); 方法</p> <p><strong>注:<em>onPageStart</em>和<em>onPageEnd</em>须成对调用。</strong></p> <p>例如:某apk将监测&ldquo;关于&rdquo;html界面,其对应html名称为About.html</p> <p>代码片段示例如下:</p> <p>&nbsp;&lt;script&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;function myclick() {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById(&quot;demo&quot;).innerHTML=Date();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bonreeJsBridge.onPageStart(&quot;1&quot;,&quot;About&quot;);</p> <p>bonreeJsBridge.onPageEnd(&quot;1&quot;,&quot;About&quot;);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&lt;/script&gt;</p> <p><strong>3.</strong><strong>js</strong><strong>代码中</strong><strong>用户自定义信息的统计</strong></p> <p>字段说明:</p> <p>Kv:自定义信息的Map&lt;String,Object&gt;集合</p> <p>在需要添加自定义信息的模块调用</p> <p><em>bonreeJsBridge</em>.setUserInfo(String kv);</p> <p>例如:某html页面在进入某一个页面时设置自定义信息</p> <p>代码片段示例如下:</p> <p>&lt;script&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;function myclick() {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;document.getElementById(&quot;demo&quot;).innerHTML=Date();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;var json = &#39;{ &quot;js1&quot;: &quot;jsvalue1&quot;, &quot;js2&quot;: &quot;jsvalue1&quot;, &quot;js3&quot;:&quot;jsvalue3&quot; }&#39;;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;bonreeJsBridge.setUserInfo(json);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&lt;/script&gt;</p> <p><strong>4</strong><strong>.</strong><strong>用户自定义JS崩溃轨迹的统计</strong></p> <p>字段说明:</p> <p>arrTrace:自定义信息的String[] ,字符串数组,长度为2,第⼀个元素为视图名称(或者标题),第二个元素为事件名(或者详情)</p> <p>在需要添加自定义信息的js代码模块中调用</p> <p>bonreeJsBridge.addCrashTrace(String[] arrTrace)</p> <p>例如:html页面点击按钮时设置自定义信息</p> <p>代码片段示例如下:</p> <p>&nbsp;&lt;script&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;function myclick() {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;document.getElementById(&quot;demo&quot;).innerHTML=Date();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;bonreeJsBridge.addCrashTrace([&#39;homePage&#39;,&#39;just run a test&#39;]);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&lt;/script&gt;</p> <p><strong>5</strong><strong>.AngularJS</strong><strong>崩溃统计(适用于AngularJs框架)</strong></p> <p>字段说明:</p> <p>arrAngularError:崩溃信息的String[] ,字符串数组(按调⽤用示例传入参数即可)</p> <p>js代码模块中调用</p> <p>bonreeJsBridge.angularError(String[] arrAngularError);</p> <p>例如:配置AngularJs崩溃收集功能</p> <p>代码片段示例如下:</p> <p>&lt;script&gt;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var app = angular.module(&#39;myApp&#39;, []);</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; app.controller(&#39;myCtrl&#39;, function($scope) {</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $scope.count = 0;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $scope.myFun=function(){</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; console.log(aaa);</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $scope.count+=1;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; app.config(function($provide) {</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $provide.decorator(&quot;$exceptionHandler&quot;, function($delegate) {</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return function(exception, cause) {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bonreeJsBridge.angularError([exception.name,exception.message,window.location.href,na vigator.userAgent,exception.stack]);</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $delegate(exception, cause);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });</p> <p>&lt;/script&gt;</p> <p>&nbsp;</p> <p><strong>Part</strong><strong>D</strong><strong>:</strong><strong>Native</strong><strong>数据监测</strong></p> <p><strong>1</strong><strong>.</strong><strong>用户自定义Native崩溃轨迹的统计</strong></p> <p>字段说明:</p> <p>traceName:String 字符串类型,视图名称(或者标题)</p> <p>traceValue: String字符串类型,事件名(或者详情)</p> <p>需要添加自定义信息的Native代码模块中调用</p> <p>代码片段示例如下:</p> <p>&nbsp;jclass clazz = env-&gt;FindClass(&quot;com/bonree/net/format/NativeCrashJniUtil&quot;);</p> <p>&nbsp;&nbsp;&nbsp; if (clazz != NULL) {</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jmethodID methods = env-&gt;GetMethodID(clazz, &quot;addCrashTrace&quot;, &quot;(Ljava/lang/String;Ljava/lang/String;)V&quot;);</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jobject jobj = env -&gt; AllocObject(clazz);</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; env-&gt;CallVoidMethod(jobj,methods,env-&gt;NewStringUTF(&quot;traceName&quot;),env-&gt;NewStringUTF(&quot;traceValue&quot;));</p> <p>&nbsp;&nbsp;&nbsp; }</p>
以上内容是否解决了您的问题?
请补全提交信息!
咨询·建议

电话咨询 - 7x24 小时

400-151-8800

邮件咨询

cloud@pingan.com

在线客服

7x24 小时,急速解答

工单支持

解决云产品相关技术问题