contents
Preface
text
1. Introduction to U-APM Application Performance Monitoring Platform
- Big core advantage
- Function comparison of U-APM and other products
Steps to integrate the Youmeng SDK
The first step, enter the U-APM function home page
The second step, fill in the application information and register
The third step, download and integrate the basic SDK
The fourth step, the initialization code
Step 5: Observe the console statistics
3. Problems encountered during SDK integration
Question 1. Error: The package com.umeng.commonsdk does not exist
Question 2. After the SDK is integrated, the monitoring platform does not see relevant statistics
Question 3. Error: Installation did not succeed. The application could not be in-stalled: INSTALL_FAILED_CONFLICTING_PROVIDER
4. Positioning and solving actual problems - Crash case analysis
- Set alarm policy
- Other functions
end
Preface
Umeng has launched a new application performance monitoring platform U-APM. U-APM can help us understand the performance and stability of applications and help us efficiently improve the quality of applications. Through real-time collection of crash information after the new version is launched, it provides a variety of key information to assist in locating problems and multi-dimensional analysis reports, so that problems can be quickly discovered, located, and resolved.
text
1. Introduction to U-APM Application Performance Monitoring Platform
1. Big core advantage
1) Abundant types of capture and collection, support Java, Native, Swift, Objective-C, ANR, custom exception capture.
2) Quickly locate the root cause of the error, provide behavior logs, detailed logs, memory snapshots, device information, and custom fields to help you quickly find the cause of the problem and improve the efficiency of problem solving.
3) Intelligent alarm professional services, providing email, nailing, flying book, enterprise WeChat alarm access channels, multi-time period, multi-indicator combined alarm, helping you to monitor the application situation 7*24 hours. Provide professional customer service + technical support, enrich user courses, offline salons, etc. to help you get started quickly.
4) Mainstream popular models, get massive Android and iOS cloud real devices anytime and anywhere, stable and never dropped, smooth operation without delay, saving millions of real device purchase costs, and ensuring the quality of the app.
2. Function comparison between U-APM and other products
Steps to integrate the Youmeng SDK
If you want to integrate Umeng's SDK, certain steps are required. In similar products, the process is not algorithmically complicated, but it is not very simple. As for how to make it more convenient, can you consider omitting the steps of filling in application information? Well, leave this question to our product classmates. Next, we begin to introduce in detail.
The first step, enter the U-APM function home page
U-APM function experience link address: https://at.umtrack.com/q0Dmaa
The second step, fill in the application information and register
Enter the application creation interface, first fill in the application name AVPlayer, and then select the platform. It should be noted that Umeng supports iPhone, iPad, and Android three mobile terminal platforms. We choose Android, and the default Chinese is the application language. Our application is a player, so the application type chooses movie watching/local playback. Finally, fill in the basic description information of the application and click the "register application" button.
After completing the registration, the system will give the AppKey of the application. For confidentiality, part of the content is hidden in the screenshot, please forgive me.
The third step, download and integrate the basic SDK
There are two ways to integrate the basic SDK, namely online access to the SDK and manual integration of the SDK. At present, it may be due to the compatibility of the old and new versions that the official recommendation is to use the online SDK for new apps.
Then we will keep pace with the times and take the new version of the APP integration SDK as an example to demonstrate.
- Add the sdk maven warehouse address in the buildscript and allprojects sections of the project build.gradle configuration script.
The configuration method is as follows:
buildscript {
repositories {
google()
jcenter()
maven { url 'https://repo1.maven.org/maven2/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://repo1.maven.org/maven2/' }
}
} - Integrate and componentize various business SDKs
The required SDK can be flexibly configured in maven, and the dependencies of the basic component library and statistical SDK library can be added to the dependencies section of the project App corresponding to the build.gradle configuration script.
The configuration method is as follows:
// Youmeng basic component library (all Youmeng business SDKs rely on the basic component library)
implementation "com.umeng.umsdk:common:9.4.2" // version number (required))
implementation "com.umeng.umsdk:asms:1.4.1" // asms package dependency (required)
implementation "com.umeng.umsdk:apm:1.4.2" // U-APM product package dependency (required)
Code example: - Function dependency library introduction
Of course, you can also add other functional dependent libraries according to the actual needs of the application APP. There are many types of dependent libraries, such as:
1) Youmeng basic component library (all Youmeng business SDKs rely on the basic component library)
2) Youmeng Statistics SDK depends on coordinates
3) Application performance monitoring SDK depends on coordinate library
4) Youmeng shares SDK core library
5) Support the Umeng sharing module that gradle depends on online
6) Youmeng pushes SDK dependent coordinates
7) Vendor push dependent coordinates (all relevant components under a single vendor channel must be integrated, for example: Xiaomi channel integrates 2 components)
The fourth step, the initialization code
Initialize the interface for each business uniformly. There are three points in total, which are introduced below.
1) Join Union+SDK compliance statement in privacy compliance
https://developer.umeng.com/docs/147377/detail/213789. This is very necessary, and the review has been very strict recently, especially for mobile apps.
2) Call the pre-initialization function UMConfigure.preInit() in the Applicaiton.onCreate function
Sensitive friends, I will immediately ask a question here: Will this method of calling Youmeng affect the mobile speed of the APP? The answer is to worry too much. As a pre-initialization function, preInit() takes very little time and will not affect the user experience of the first cold start of the App. It will not collect device information or report data to the Umeng background.
Youmeng pre-initialization function is declared as follows:
public static void preInit(Context context, String appkey, String channel)
The code screenshot is as follows:
3) After the user agrees to the privacy policy, the client begins to formally initialize the Youmeng SDK
The initialization function UMConfigure.init() is called, and the initialization function of Umeng is declared as follows:
UMConfigure.init(Context context, String appkey, String channel, int deviceType, String pushSecret)
The code screenshot is as follows:
Step 5: Observe the console statistics
After completing the settings, we return to the home page to view the corresponding APP application statistics, including the number of exceptions, the number of affected users, the number of alarms, and the remaining minutes of the cloud real machine.
3. Problems encountered in the process of integrating SDK
Question 1. Error: The package com.umeng.commonsdk does not exist
Personally, this is the most common kind of error, but there is no relevant description in the official document. The official FAQ list address: https://developer.umeng.com/docs/119267/detail/181401, I feel that many of the contents are summarized by the official itself and are not grounded enough. For example, I don’t know where this error should go. one type. Can the official consider adding a community module to facilitate communication between developers? The specific location can refer to the following figure:
In the end, after a long time of tossing, I did not integrate the Youmeng SDK through the online mode, and later switched to the local dependency mode to solve this problem.
Question 2. After the SDK is integrated, the monitoring platform does not see relevant statistics
This problem was caused by my negligence. I thought it was enough to pass in AppKey when calling the UMConfigure.preInit() method. The UMConfigure.init() method is not updated synchronously, which causes this problem. I also conclude from this that the method that really plays a role in association is UMConfigure.init(). Of course, I also look forward to a more reasonable official explanation, because my understanding may be wrong.
Question 3. Error: Installation did not succeed. The application could not be in-stalled: INSTALL_FAILED_CONFLICTING_PROVIDER
After integrating the Youmeng SDK, this error was reported when installing the APP. Later, the old APP was uninstalled from the mobile phone and reinstalled, and the problem was solved. In this way, it doesn't have much to do with the Integrated Alliance SDK, but this problem is so magical.
4. Positioning and solving actual problems
After we complete the Youmeng SDK integration, we can find the corresponding application name integration status shows "Integrated" through the back-end homepage. At the same time, we can also view the running status of the application, such as the number of exceptions and the number of affected users.
Next, we analyze according to the specific abnormal monitoring results.
1. Crash case analysis
Through the "Analysis" tab in the background, find the "Crash Analysis" module, you can find that there is a crash error today.
Scroll down on the current page, we can see the corresponding error list and error distribution. Among them, the error list includes the summary of the error occurrence, ID, last time of occurrence, error type, version range, number of errors, number of affected users, processing status, etc. The specific content is shown in the following figure:
Error distribution includes device distribution, system distribution, operator distribution, version distribution, page distribution, duration distribution, channel distribution, and geographic distribution. The specific content is shown in the following figure:
Okay, next, let's analyze this error in detail. Click the link of the error summary in the error list to enter the error details. There are specific details of the error. For example, the cause of the error shown in the figure below is that the array is out of bounds: ArrayIndexOutOfBoundsException. The specific code location is in line 93 of the file UappActivity.java.
We find the number of corresponding lines of code and take a look at the code situation. The specific screenshots are as follows:
Wow, when we saw the code and combined with the error message, we immediately knew that there was a problem with this line of code. The size of the array is 3, the index value is up to 2, and it cannot be 3. Modify it to 0, 1, 2, and the problem is solved .
Recompile and install, run again to see the effect, perform the same operation, the crash no longer occurs. At this point, we can manually modify the processing state of the crash. For example, as shown in the figure below, change "unrepaired" to "repaired", which also includes two other states, namely "processing" and "repaired". neglect".
2. Set the alarm policy
In addition, we can also set warning strategies for certain types of errors, such as the crash problem above, if we are not sure whether it is really solved. Then you can click the "Alarm" button to enter the alarm policy setting page.
In the new alarm plan page, we need to set the name of the alarm plan. Generally, the error name + error ID is used, but be careful not to exceed 20 characters. At the same time, you can also set the alarm effective time, the default real-time notification, you can also customize the notification time period, such as every Tuesday from 3 pm to 4 pm.
In addition, you can also customize the alarm trigger conditions, which will generally take effect when the number of error occurrences is greater than 0. You can also specify the effective application version. For example, if I only want to monitor the latest version 3.0 of the APP application, I can select the corresponding version from the drop-down list. The notification method can be at least one of Email, DingTalk, Enterprise WeChat, and Feishu. The common methods are the first two.
However, in the actual use process, I tried two alarm plans, but the mailbox did not receive the corresponding notification. It seems that there is no official version limit for this function, and the notification message list is also empty, which is very strange. I originally wanted to leave this problem for future investigation. However, I didn't know how long it took and received an email notification. It seems that the delay is still quite large. The screenshot of the email is as follows:
3. Other functions
In addition to the crash analysis and alarm notification functions introduced above, U-Meng's application performance monitoring platform U-APM also has functional modules such as ANR analysis, custom exceptions, freeze analysis, startup analysis, memory analysis, and network analysis.
1) ANR analysis. ANR is an ANR when a pop-up appears when the user is using the Android APP, prompting that the application is not responding. The stability module can capture the ANR that occurs in the main process and the child process. Through the calculation of the number of occurrences of ANR, it shows developers the error trend, error distribution and error list of the App in the selected time, and can quickly analyze the main reasons that cause the APP to occur ANR.
Note: To activate the monitoring ANR function, Android needs to integrate Common 9.3.8 and above + APM 1.1.0 and above version number. iOS needs to integrate Common 7.2.8 and above + APM 1.1.0 and above version number, and it will be automatically collected after the upgrade.
2) Custom exceptions. Developers can define certain exception types by themselves. The program captures the exceptions. In order to better understand and monitor these exceptions, the developers also report these exceptions to the error analysis service of Youmeng+ middle. I have to say that there are still many application scenarios for this function, and Bugly also has similar functions.
3) Stall analysis, when the message setting time exceeds the defined threshold of stutter, it will be recorded as stutter, which can be used as an index to judge application performance. Solving the stuttering problem is of great significance in improving the user experience. Reasonably optimizing stuttering indicators is a medium and long-term task in the APP development process.
Note: To use the lagging function, Android needs to integrate Common 9.3.8 and above + APM 1.2.0 and above version number. iOS needs to integrate Common 7.2.8 and above + APM 1.2.0 and above version number, and it will be automatically collected after the upgrade.
4) Startup analysis, including startup trend, slow startup analysis, and startup crash analysis. By monitoring the average, quantile, interval distribution and other data of the start-up time of the APP, as well as the performance decomposition data during the startup phase, analyze the causes of slow startup and startup crashes.
5) Memory analysis, including OOM exceptions and memory usage. Provides the memory overflow, memory occupancy and distribution details of the APP during the running phase, so that we can analyze the health of the application and locate the problem.
6) Network analysis: Analyze the current application network conditions by collecting data on HTTP requests, network errors, DNS resolution and other dimensions, which is helpful for developers to locate network-related coding problems, such as timeout processing, network disconnection and reconnection and other common problems.
end
Through the introduction of this article, we can see that the integration process of the U-Meng application performance monitoring platform U-APM is relatively simple. In addition, the U-APM platform has rich data collection and functional analysis capabilities, and the specific functional granularity is divided The aspects are also very detailed. Compared with similar products, such as Bugly, NetEase Cloud Capture, etc., it is much more powerful. In addition, I also encountered some in the process of integration and use, and they are reflected in the article. I hope that the U-Meng team will continue to improve the U-APM platform and bring new gospel to the guys who develop mobile terminals.
Author: Liu Zhen
Community pseudonym: liuzhen007 (Data-Mining)
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。