FAQ
1、Application Launch Data Not Collected or Lifecycle Methods Missing。
-
If a custom MyBaseActivity is registered in the AndroidManifest.xml file, please remove it or configure it to filter embedded coding. Filtering requires adding the following content to the tingyun.properties file:
#Replace "=" with the path of the class you want to filter for embedded coding, separate multiple paths with an English comma.
noInstrumentedClasses=com/nbs/ui/base/MyBaseActivity -
The application needs to implement a custom Application class.
2、User Operation Data Collection Insufficient。
The Diatone SDK embeds code for click events (such as onClick, onItemClick, ItemSelected, PageSelected, etc.) during compilation, only supporting click data collection, and does not currently support touch or swipe operations.
3、No Crashes Collected or Fewer Crashes Than Expected
- The Diatone SDK has supported Native Crash exception collection since version 2.11.1, with previous versions only collecting Java Crashes.
- Crashes that occur before the initialization of the Diatone SDK cannot be collected.
- Check if the crash collection switch in the report is turned on.
- If there is an application-specific exception capture or third-party crash collection logic in the application, it needs to be initialized before the Diatone SDK.
4、TCP, SSL, and Other Metric Data Are 0
- The Diatone SDK needs to be initialized before the application's own network requests are initiated.
- Android 8.1 and above only support OkHttp3 for collecting TCP, SSL, and other metric data.
- TCP data cannot be collected when using an HTTP proxy.
- If the WebView cross-domain resource response header is not configured with Timing-Allow-Origin: *, it will not be collected.
5. WebView Data Not Collected or Only Network Errors and HTTP Errors Are Collected
- If the method NBSWebChromeClient.initJSMonitor(view, newProgress) is not called in the onProgressChanged method of WebChromeClient.
- Data collection for SPA (Single Page Application) is not supported.
- Data collection for loading HTML code using loadDataWithBaseURL is not supported.
6. URL Filtering and Error Filtering Not Effective
Check if the configuration on the report is correct, and you can use an online regular expression tool to check. Note that the regular expression in the report configuration needs to have slashes “/” added before and after.
7. java.lang.NoClassDefFoundError Exception Occurs on Devices Running Android 5.0 or Lower When Using MultiDex
The classes that cause the error should be allocated to the main dex, and you can refer to the solution provided by Google.
8. Sophix Patch Tool Fails to Generate Patch
The Diatone SDK embeds code in the Application class's attachBaseContext() and onCreate() methods during compilation to collect application launch data. However, since version 3.2.1, the Ali Hotfix patch tool requires that no non-Android official API calls be made before the initialize method, leading to a failure in generating the patch.
Solution
To pass the patch tool's check, Diatone cannot embed code in the Application class during compilation. You can filter the Application class in the Diatone tingyun.properties configuration file. This will affect Diatone's ability to collect application launch data, so manual embedding is required for the Application class.
- In the tingyun.properties configuration file (create one if it doesn't exist, one in the project root directory and one in the main module), configure filtering for the Ali Application class and the project's own RealApplication class:
#Replace the equals sign "=" with the full class name, replace dots with slashes, and separate multiple class names with an English comma.
#com/nbs/app/MyApp is an example and should be replaced with the actual real Application class of the project.
noInstrumentedClasses=com/nbs/app/SophixStubApplication,com/nbs/app/MyApp
2、 Add the following code to the onCreate() method of the project's Application class:
NBSAppInstrumentation.attachBaseContextBeginIns(this.getApplicationContext());
NBSAppInstrumentation.attachBaseContextEndIns();
NBSAppInstrumentation.applicationCreateBeginIns();
NBSAppInstrumentation.applicationCreateEndIns();
Example:
@Override
public void onCreate() {
// Add at the beginning of onCreate()
com.networkbench.agent.impl.instrumentation.NBSAppInstrumentation.attachBaseContextBeginIns(this.getApplicationContext());
com.networkbench.agent.impl.instrumentation.NBSAppInstrumentation.attachBaseContextEndIns();
com.networkbench.agent.impl.instrumentation.NBSAppInstrumentation.applicationCreateBeginIns();
super.onCreate();
//...other code
// Add at the end of onCreate() com.networkbench.agent.impl.instrumentation.NBSAppInstrumentation.applicationCreateEndIns();
}
Note:
1.After hotfixing, test on Android 9 or higher devices to see if Diatone can start normally. Check for the "NBSAgent connect success" log. If it does not start normally, you may need to add the following class to the whitelist in the Ali patch tool:
com.networkbench.agent.impl.NBSAgent
2.After hotfixing, test if Diatone can collect crashes. Since Ali registers the CrashHandler twice at startup and after 3 seconds, but only retrieves the defaultHandler at startup, if the application crashes after 3 seconds, Ali will skip the previously registered third-party CrashHandler and throw it directly to the system, preventing third-party collection of the crash. Contact Ali to modify their CrashHandler logic.
Reference Material
For troubleshooting steps of the Hotfix patch tool, please refer to the Aliyun introduction。
9. java.util.zip.ZipException Occurs During Compilation
The SDK jar package is referenced multiple times. Check the libs directory and the build.gradle file to ensure there is only one reference to nbs.newlens.agent.jar.
10. Compilation Failure When Using Lambda
Place the Diatone plugin after lambda:
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'newlens'
11. SDK Compilation Time Issue
The principle of the Diatone SDK is bytecode instrumentation (using the Transform API), which can affect the project's compilation time to some extent. We provide a configuration that allows Diatone SDK not to participate in compilation during development. If your project is large and you feel a significant increase in compilation time after integrating the Diatone SDK, you can configure it as follows:
- Open the build.gradle file in the app directory.
- Add the following content:
newlensExt {
newlensEnabled = false //Set to false to prevent the project from being instrumented, set to true before submitting for testing and before going live
}
12. Multiple dids Appear on the Same Device in Reports
Since version 2.14.2, the Diatone SDK no longer collects device information such as IMEI. The did is issued by the server when the application is first launched and cached locally. If the application is uninstalled and reinstalled during testing, or if the application's data is "cleared," the local cache of the did will be cleared, and a new did will be issued when the application is started again.
13. Do Not Add the process Attribute to the application in AndroidMainfest.xml
Since version 2.14.2, the Diatone SDK no longer collects device information such as IMEI. The did is issued by the server when the application is first launched and cached locally. To prevent multiple processes from initializing concurrently and receiving different dids, the SDK has restrictions on multiple processes, meaning that if there is no local cache of the did, the child process will not initialize. The SDK uses the package name and process name for process judgment, and if the process attribute is added to the application, the SDK may stop collecting data.
14. How to Pass Custom Business Data to BPI
Define a [Business Operation] through "Custom Operations" to understand its performance. This interface's data is only displayed in the BPI report.
1、Related Interface
Note: The "Custom Operation" interface needs to be called in pairs, and actionName cannot be empty, supporting cross-method and cross-thread calls.
customActionStart(String actionName);
customActionEnd(String actionName, String tag, Map cust);
2、Code Example
private void login() {
NBSAppAgent.customActionStart(“login”);
………
Map cust = new HashMap();
cust.put("userName","abc");
NBSAppAgent.customActionEnd(“login”,"tag",cust);
}
15. SDK Initialization Fails to Connect to the Server Over HTTP
The SDK defaults to uploading data over HTTPS. If the server only supports HTTP, you need to set 'setHttpEnabled(true)'. Android 9.0 and above versions restrict HTTP requests, which can be resolved by adding a network_security_config.xml configuration.
Create a new xml directory in res, then create a new network_security_config.xml file.
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
Add networkSecurityConfig to the application in the manifest file.
<application
...
android:networkSecurityConfig="@xml/network_security_config"
...
/>