├── .gitignore
├── LICENSE
├── README-EN.md
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── apminsightdemo
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── apminsightdemo
│ │ │ ├── App.java
│ │ │ ├── BlockListActivity.java
│ │ │ ├── FirstActivity.java
│ │ │ ├── HybridTestActivity.java
│ │ │ ├── MainActivity.java
│ │ │ └── fragment
│ │ │ └── ListFragment.java
│ └── res
│ │ ├── layout
│ │ ├── activity_block_list.xml
│ │ ├── activity_hybrid_main.xml
│ │ ├── activity_main.xml
│ │ └── item_block_scrolling.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── apminsightdemo
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | .idea
4 | /local.properties
5 | /.idea/caches
6 | /.idea/libraries
7 | /.idea/modules.xml
8 | /.idea/workspace.xml
9 | /.idea/navEditor.xml
10 | /.idea/assetWizardSettings.xml
11 | .DS_Store
12 | /build
13 | /captures
14 | .externalNativeBuild
15 | .cxx
16 | /.idea/
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Volcengine
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README-EN.md:
--------------------------------------------------------------------------------
1 | [中文版本](README.md)
2 | # APMPlusDemo
3 | This is an example of APMPlus SDK. Enter official website to read the introduction of SDK capabilities and access.
4 | 1. [APMPlus Android Official Website](https://www.volcengine.com/docs/6431/68852)
5 | 2. [APMPlus Android Q&A](https://www.volcengine.com/docs/6431/127838)
6 |
7 | ### Usage
8 | 1. The demo APP has integrated all capabilities of APMPlus.
9 | 2. You can make errors and performance data in the demo APP.
10 | 3. The data is shown on APMPlus.
11 | #### Request for access to demo data
12 | * Register an account for APMPlus. [Go to Register](https://www.volcengine.com/products/apmplus)
13 |
14 | ### License
15 | APMPlus_Android is available under the MIT license. See the [LICENSE](LICENSE) file for more info.
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [ENGLISH](README-EN.md)
2 | # APMPlusDemo
3 | 这是 APMPlus Sdk的使用示例. 下面链接有详细的Sdk接入和使用说明
4 | 1. [APMPlus Android 接入文档](https://www.volcengine.com/docs/6431/68852)
5 | 2. [APMPlus Android Q&A](https://www.volcengine.com/docs/6431/127838)
6 |
7 | ### Demo使用说明
8 | 1. 这个demo已经接入了所有APMPlus的性能和稳定性监控的能力。
9 | 2. 可以在这个demo里面模拟异常和性能数据收集上报。
10 | 3. 数据会上报到APMPlus平台,可以配置成自己项目的Aid进行SDK功能测试。
11 | #### 注册并查看demo上报的数据
12 | 1. 在APMPlus平台注册一个账号。[注册地址](https://www.volcengine.com/products/apmplus)
13 | 2. 然后修改demo里的Aid进行测试。
14 | ### 开源许可协议
15 | APMPlus_Android 使用 MIT 协议,具体内容查看 [LICENSE](LICENSE)
16 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'apm-plugin'
3 |
4 |
5 | android {
6 | compileSdkVersion 34
7 | buildToolsVersion "29.0.3"
8 |
9 | defaultConfig {
10 | applicationId "com.example.apminsightdemo"
11 | minSdkVersion 18
12 | targetSdkVersion 34
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
17 |
18 | manifestPlaceholders.put("APPLOG_SCHEME", "insight".toLowerCase())
19 |
20 | }
21 |
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
26 | }
27 | }
28 | compileOptions {
29 | sourceCompatibility 1.8
30 | targetCompatibility 1.8
31 | }
32 | }
33 |
34 | dependencies {
35 | implementation fileTree(dir: 'libs', include: ['*.jar'])
36 |
37 | //apm性能组件
38 | implementation 'com.volcengine:apm_insight:1.5.3.cn'
39 | //apm稳定性组件
40 | implementation 'com.volcengine:apm_insight_crash:1.5.0'
41 |
42 | implementation "com.squareup.okhttp3:okhttp:3.14.0"
43 |
44 | implementation 'com.android.support:appcompat-v7:28.0.0'
45 | implementation 'com.android.support:recyclerview-v7:28.0.0'
46 | testImplementation 'junit:junit:4.12'
47 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
48 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
49 |
50 | }
51 |
52 | ApmPlugin {
53 | // 是否进行插桩
54 | enable true
55 | // 是否在Debug包插桩,默认插桩
56 | enableInDebug true
57 | // DEBUG("DEBUG"), INFO("INFO"), WARN("WARN"), ERROR("ERROR");
58 | // INFO 级别Log会汇总所有被插桩处理的类供查看,路径 app/build/ByteX/ApmPlugin
59 | logLevel "DEBUG"
60 | // 监控App启动耗时,需要同时开启pageLoadSwitch
61 | startSwitch = true
62 | // 监控Activity的生命周期耗时
63 | pageLoadSwitch = true
64 | // 监控okhttp3的网络请求
65 | okHttp3Switch = true
66 | // 只对白名单下的包进行插桩。可以填写自己的包名。不配置则不会插桩,影响网络监控也启动监控等功能。
67 | whiteList = [
68 | "com"
69 | ]
70 | // 黑名单包下类不进行插桩,可以配置包名和类名。没有可以为空
71 | blackList = [
72 | ]
73 | }
74 |
75 |
76 | apply from: 'https://lf-apmplus.volccdn.com/obj/apminsight-symbolicate/apminsight.gradle'
77 | apminsightConfig {
78 | api_token = "" // 从平台的 全部功能->符号表管理->系统选择 Android->下面可以看到api key和api token。或者联系开发同学获取到的对应appId的一个token,私有化部署不用填
79 | api_key = 0 // 从平台的 全部功能->符号表管理->系统选择 Android->下面可以看到api key和api token。或者联系开发同学获取到的对应appId的一个key,私有化部署不用填
80 | aid = 187277 // 平台上的appid
81 | // update_version_code = -1 // 默认不用写这一行, 除非你初始化时候手动指定了非标准版本号(或SDK版本号); 此处一定要与apmInsight初始化的版本号一致
82 | // mappingUrl = "https://www.xxx.com" // 默认不用写这一行,如果是私有化,这里配置私有化域名
83 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/apminsightdemo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.apminsightdemo;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
23 |
24 | assertEquals("com.example.apminsightdemo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
16 |
17 |
20 |
21 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/apminsightdemo/App.java:
--------------------------------------------------------------------------------
1 | package com.example.apminsightdemo;
2 |
3 | import android.app.Activity;
4 | import android.app.Application;
5 | import android.util.Log;
6 |
7 | import com.apm.insight.ExitType;
8 | import com.apm.insight.MonitorCrash;
9 | import com.apm.insight.log.VLog;
10 | import com.bytedance.apm.insight.ApmInsight;
11 | import com.bytedance.apm.insight.ApmInsightInitConfig;
12 | import com.bytedance.apm.insight.IActivityLeakListener;
13 | import com.bytedance.apm.insight.IDynamicParams;
14 |
15 |
16 | /**
17 | * Application
18 | *
19 | * @author steven
20 | * @date 2020/11/11
21 | */
22 | public class App extends Application {
23 | public static String sSDKAid = "187277";
24 | public static String sToken = "token";
25 | public static String did = "device_id";
26 | public static String uid = "user_id";
27 |
28 | public static MonitorCrash mMonitorCrash;
29 | private static boolean hasStart;
30 | private static boolean hasInit;
31 |
32 | @Override
33 | public void onCreate() {
34 | super.onCreate();
35 | initMonitor(this);
36 | }
37 |
38 | /**
39 | * 初始化APM监控,不会立即采集数据,需要放到Application的onCreate执行
40 | *
41 | * @param application
42 | */
43 | private void initMonitor(Application application) {
44 | if (hasInit) {
45 | return;
46 | }
47 | hasInit = true;
48 | initCrash(application);
49 | initApmInsight(application);
50 | }
51 |
52 | /**
53 | * 崩溃监控初始化
54 | */
55 | public static void initCrash(Application application) {
56 | MonitorCrash.Config config = MonitorCrash.Config.app(sSDKAid)
57 | .token(sToken)// 设置鉴权token,可从平台应用信息处获取,token错误无法上报数据
58 | // .versionCode(1)// 可选,默认取PackageInfo中的versionCode
59 | // .versionName("1.0")// 可选,默认取PackageInfo中的versionName
60 | // .channel("test")// 可选,设置App发布渠道,在平台可以筛选
61 | // .url("www.xxx.com")// 默认不需要,私有化部署才配置上报地址
62 | //可选,可以设置自定义did,不设置会使用内部默认的
63 | .dynamicParams(new MonitorCrash.Config.IDynamicParams() {
64 | @Override
65 | public String getDid() {//返回空会使用内部默认的did
66 | return did;
67 | }
68 |
69 | @Override
70 | public String getUserId() {
71 | return uid;
72 | }
73 | })
74 | //可选,添加业务自定义数据,在崩溃详情页展示
75 | // .customData(crashType -> {
76 | // HashMap map = new HashMap<>();
77 | // map.put("app_custom", "app_value");
78 | // return map;
79 | // })
80 | .exitType(ExitType.EXCEPTION) //上报应用退出原因,EXCEPTION会过滤USER_REQUEST类型
81 | .enableApmPlusLog(true) // 是否将崩溃信息等写入APMPlus日志,默认false
82 | // .crashProtect(true) //是否开启崩溃防护,默认true
83 | .autoStart(false) // 是否在初始化时自动开启监控,默认为true
84 | // .debugMode(true) //线下使用的日志开关,线上不要调用或设置为false
85 | // 可选,添加pv事件的自定义tag,可以用来筛选崩溃率计算的分母数据
86 | //.pageViewTags(<