Tencent Bugly official website bugly.qq.com/ Bugly official document bugly.qq.com/docs/ App upgrade SDK advanced configuration bugly.qq.com/docs/user-g…

This article simplifies official documentation and provides quick access to Bugly’s exception reporting and app updates on Android.

1. Create new products on the official website

2. To get the APP ID, click Product Settings to get the APP ID

3. Integrate SDK in Android projectapp/build.gradleThe SDK is automatically integrated into the file

Android {defaultConfig {NDK {// set the supported SO library architecture abiFilters 'armeabi', 'x86', 'armeabi-v7a', 'x86_64', }} count count count count count count count count count count count count count 'com. Tencent. Bugly: crashreport_upgrade: 1.4.2' / / bugly Native Crash capture implementation 'com. Tencent. Bugly: nativecrashreport: 3.7.1'}Copy the code

4. Androidmainfest.xml configuration, inAndroidMainfest.xmlTo perform the following configuration:

  • Access configuration

Note: If your App needs to be uploaded to the Google Play Store, you need to block or remove the READ_PHONE_STATE permission, otherwise it may be removed.

<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" />Copy the code
  • Activity configuration and FileProvider configuration

Note: If you want to be compatible with Android N or higher devices, you must configure the FileProvider in the Androidmanifest.xml file to access files in the shared path.

<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-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/> </provider>Copy the code

Create a new XML folder in the RES directory and create a provider_Paths.xml file with the following contents:

<? The 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>Copy the code

5. Confuse the configurationProguard – rules. Pro fileadd

Add the following to the proGuard-rules.pro file if code obturation is turned on in your project, ignore this step if obturation is not turned on.

-dontwarn com.tencent.bugly.** -keep public class com.tencent.bugly.**{*; } -keep class android.support.**{*; }Copy the code

6. Initialize Bugly

Note: If your project already has a custom Application file, add code directly to the onCreate method: bugly.init (getApplicationContext(), “AppID obtained in step 2 “, false);

  • Create a new myapp.java with the following code:
public class MyApp extends Application { @Override public void onCreate() { super.onCreate(); Bugly.init(getApplicationContext(), "AppID obtained in step 2 ", false); }}Copy the code
  • Android :name=”.myapp”

7. Access is complete

Now you can make a Crash (triggered by a “keystroke” is recommended) to experience Bugly’s abilities. After initializing Bugly’s, you can call Bugly’s Java Crash interface.

The test code: CrashReport testJavaCrash (); A Crash occurs when executing this code