首先声明 咱们这里使用的是gradle自动集成 和 同时集成SDK和NDK模式.选择初始化bugly的方式是代码初始化java
在 在Module的build.gradle文件中添加依赖和属性配置:android
android { defaultConfig { ndk { // 设置支持的SO库架构 abiFilters 'armeabi' //, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a' } } } dependencies { compile 'com.tencent.bugly:crashreport:latest.release' //其中latest.release指代最新Bugly SDK版本号,也能够指定明确的版本号,例如2.1.9 compile 'com.tencent.bugly:nativecrashreport:latest.release' //其中latest.release指代最新Bugly NDK版本号,也能够指定明确的版本号,例如3.0 }
注意:自动集成时会自动包含Bugly SO库,建议在Module的build.gradle文件中使用NDK的“abiFilter”配置,设置支持的SO库架构。
架构
若是在添加“abiFilter”以后Android Studio出现如下提示:ide
NDK integration is deprecated in the current plugin. Consider trying the new experimental plugin.
测试
则在项目根目录的gradle.properties文件中添加:gradle
android.useDeprecatedNdk=true
ui
<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" />
-dontwarn com.tencent.bugly.** -keep public class com.tencent.bugly.**{*;}
CrashReport.initCrashReport(getApplicationContext(), "注册时申请的APPID", false); //最简单的初始化
其实Bugly的集成挺简单的,可是功能仍是挺强大的,里面有一些高级功能有时间能够看一看.code
地址:https://bugly.qq.com/docs/user-guide/instruction-manual-android/?v=20170322165254#_5 xml