Bugly - Bugly 基本使用( App 质量追踪平台)

Bugly

1、基本介绍
  1. Bugly 是腾讯推出的 App 质量追踪平台,专门帮开发者发现、定位、解决线上 App 的崩溃、卡顿等问题

    1. 官方网址:https://bugly.qq.com/v2/

    2. 开发文档:https://bugly.qq.com/docs/user-guide/instruction-manual-android/?v=1.0.0

  2. Bugly 优势在于免费、接入简单,适合中小团队快速搭建质量监控体系

2、场景实例
  1. 以前:用户反馈"点了一下就闪退了",开发者复现不了,无从下手

  2. 现在:Bugly 后台直接看到崩溃堆栈、机型、系统版本、操作路径,精准定位到某行代码

3、演示
(1)Setting
  1. 项目级 build.gradle
groovy 复制代码
android {
    defaultConfig {
        ndk {
            abiFilters 'armeabi'
        }
    }
}

...

dependencies {
    implementation 'com.tencent.bugly:crashreport:latest.release'
}
  1. AndroidManifest.xml
xml 复制代码
<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" />
  1. proguard-rules.pro,避免混淆 Bugly

    -dontwarn com.tencent.bugly.**
    -keep public class com.tencent.bugly.**{*;}

(2)Activity
xml 复制代码
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="MainActivity"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/btn_simulate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="模拟一个异常"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView" />
</androidx.constraintlayout.widget.ConstraintLayout>
java 复制代码
public class MainActivity extends AppCompatActivity {

    public static final String TAG = MainActivity.class.getSimpleName();

    private final String[] permissions = {
            Manifest.permission.INTERNET,
            Manifest.permission.ACCESS_NETWORK_STATE,
            Manifest.permission.ACCESS_WIFI_STATE
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        boolean needRequest = false;
        for (String permission : permissions) {
            int re = checkSelfPermission(permission);
            Log.i(TAG, "check ---------- 权限:" + permission + ",授权结果:" + re);
            if (re != PackageManager.PERMISSION_GRANTED) {
                needRequest = true;
                break;
            }
        }

        if (!needRequest) {
            next();
            return;
        }

        ActivityResultLauncher<String[]> activityResultLauncher = registerForActivityResult(
                new ActivityResultContracts.RequestMultiplePermissions(),
                o -> {
                    for (Map.Entry<String, Boolean> stringBooleanEntry : o.entrySet()) {
                        Log.i(TAG, "request ---------- 权限:" + stringBooleanEntry.getKey() + ",授权结果:" + stringBooleanEntry.getValue());
                    }

                    for (boolean granted : o.values()) {
                        if (!granted) {
                            Toast.makeText(this, "未授权权限", Toast.LENGTH_SHORT).show();
                            finish();
                            return;
                        }
                    }

                    next();
                }
        );
        activityResultLauncher.launch(permissions);
    }

    private void next() {
        CrashReport.initCrashReport(getApplicationContext(), "【App ID】", false);

        Button btnSimulate = findViewById(R.id.btn_simulate);

        btnSimulate.setOnClickListener(v -> {
            int i = 10 / 0;
        });
    }
}
相关推荐
米码收割机10 小时前
【项目】spring boot+vue3 宠物领养系统(源码+文档)【独一无二】
java·spring boot·宠物
刹那芳华199212 小时前
STMF+ESP-S+MQTT协议连接华为云端(附踩坑记录)
java·struts·华为
就改了17 小时前
Java8 日期处理(详细版)
java·python·算法
麻瓜生活睁不开眼18 小时前
Android16定制SearchLauncher新增投屏Cast桌面快捷图标完整实现
java·launcher·aosp16
ii_best18 小时前
更新!移动端开发软件按键安卓版&手机助手v5.1.0上线!本地AI识别全面解锁,脚本开发再升级
android·人工智能·ios·按键精灵
IT小盘19 小时前
12-Prompt不等于一句话-System-User-Context三层结构
java·windows·prompt
方乐寺村19 小时前
s,使用libpng提升png图片的保存速度。接下来本文将阐述在Android中如何集成libpng,以及在使用过程中遇到的问题和最 ...
android
name好难取诶19 小时前
PHP 静态分析工具实战 PHPStan 和 Psalm 完全指南
android·开发语言·php
都叫我大帅哥20 小时前
Spring Data JPA 查询之道:方法命名与示例查询完全指南
java·后端·spring
Lydia ,20 小时前
安卓基础-线性布局
android