Android如何快速集成騰訊Bugly
騰訊Bugly官方網(wǎng)址bugly.qq.com/Bugly官方文檔bugly.qq.com/docs/應(yīng)用升級(jí) SDK 高級(jí)配置bugly.qq.com/docs/user-g…
這篇文章把官方文檔化繁為簡(jiǎn),在Android中快速接入bugly的異常上報(bào)和應(yīng)用更新。
1. 新建產(chǎn)品,在官網(wǎng)新建產(chǎn)品android { defaultConfig {ndk { // 設(shè)置支持的SO庫架構(gòu) abiFilters ’armeabi’ , ’x86’, ’armeabi-v7a’, ’x86_64’, ’arm64-v8a’} }}dependencies { //bugly Java Crash捕獲和應(yīng)用升級(jí)功能 implementation ’com.tencent.bugly:crashreport_upgrade:1.4.2’ //bugly Native Crash捕獲 implementation ’com.tencent.bugly:nativecrashreport:3.7.1’}4. AndroidMainfest.xml配置,在 AndroidMainfest.xml 中進(jìn)行以下配置:
權(quán)限配置
注意:如果您的App需要上傳到google play store,您需要將READ_PHONE_STATE權(quán)限屏蔽掉或者移除,否則可能會(huì)被下架。
<uses-permission android:name='android.permission.READ_PHONE_STATE' /><uses-permission android:name='android.permission.INTERNET' /><uses-permission android:name='android.permission.ACCESS_NETWORK_STATE' /><uses-permission android:name='android.permission.ACCESS_WIFI_STATE' /><uses-permission android:name='android.permission.READ_LOGS' /><uses-permission android:name='android.permission.WRITE_EXTERNAL_STORAGE' /><uses-permission android:name='android.permission.REQUEST_INSTALL_PACKAGES' />
Activity配置 和 FileProvider配置
注意:如果您想兼容Android N或者以上的設(shè)備,必須要在AndroidManifest.xml文件中配置FileProvider來訪問共享路徑的文件。
<activity android:name='com.tencent.bugly.beta.ui.BetaActivity' android:configChanges='keyboardHidden|orientation|screenSize|locale' android:theme='@android:style/Theme.Translucent' /> <provider android:name='androidx.core.content.FileProvider' android:authorities='${applicationId}.fileProvider' android:exported='false' android:grantUriPermissions='true'> <meta-dataandroid:name='android.support.FILE_PROVIDER_PATHS'android:resource='@xml/provider_paths'/> </provider>
在res目錄新建xml文件夾,創(chuàng)建 provider_paths.xml 文件,文件內(nèi)容如下:
<?xml version='1.0' encoding='utf-8'?><paths xmlns:android='http://schemas.android.com/apk/res/android'> <external-path name='beta_external_path' path='Download/'/> <external-path name='beta_external_files_path' path='Android/data/'/></paths>5. 混淆配置,在proguard-rules.pro文件中加入
如果您的項(xiàng)目開啟了代碼混淆,請(qǐng)?jiān)?proguard-rules.pro文件 添加以下內(nèi)容,如果未開啟混淆請(qǐng)忽略這一步。
-dontwarn com.tencent.bugly.**-keep public class com.tencent.bugly.**{*;}-keep class android.support.**{*;}6. 初始化Bugly
注意:如果您的項(xiàng)目已經(jīng)有 自定義Application文件,請(qǐng)直接在 onCreate方法 添加代碼:Bugly.init(getApplicationContext(), '第2步獲取的AppID', false);
新建 一個(gè) MyApp.java,里面的內(nèi)容為以下代碼:
public class MyApp extends Application { @Override public void onCreate() {super.onCreate();Bugly.init(getApplicationContext(), '第2步獲取的AppID', false); }}
在 AndroidManifest.xml文件 的 application標(biāo)簽 中新增屬性:android:name='.MyApp'
7. 接入完成現(xiàn)在您可以制造一個(gè)Crash(建議通過“按鍵”來觸發(fā)),來體驗(yàn)Bugly的能力了。在初始化Bugly的之后,可以調(diào)用Bugly的Java Crash接口。
測(cè)試代碼 : CrashReport.testJavaCrash();執(zhí)行到這段代碼時(shí)會(huì)發(fā)生一個(gè)Crash
以上就是Android如何快速集成騰訊Bugly的詳細(xì)內(nèi)容,更多關(guān)于Android 集成騰訊Bugly的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!
相關(guān)文章:
1. .Net Core和RabbitMQ限制循環(huán)消費(fèi)的方法2. jsp文件下載功能實(shí)現(xiàn)代碼3. ASP動(dòng)態(tài)網(wǎng)頁制作技術(shù)經(jīng)驗(yàn)分享4. JSP之表單提交get和post的區(qū)別詳解及實(shí)例5. Xml簡(jiǎn)介_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理6. vue3+ts+elementPLus實(shí)現(xiàn)v-preview指令7. phpstudy apache開啟ssi使用詳解8. jsp實(shí)現(xiàn)登錄驗(yàn)證的過濾器9. 詳解瀏覽器的緩存機(jī)制10. 如何在jsp界面中插入圖片
