Frequently Asked Questions
1. Application startup data not collected or missing lifecycle methods.
-
If a custom MyBaseActivity is registered in the AndroidManifest.xml file, please delete it or configure filtering for instrumentation. Add the following to the tingyun.properties file for filtering:
# Replace the content after "=" with the class path that needs to filter Tingyun instrumentation. If there are multiple paths, separate them with commas
noInstrumentedClasses=com/nbs/ui/base/MyBaseActivity -
The application needs to implement a custom Application class
2. Limited user operation data collection.
The Tingyun SDK instruments click events (such as onClick, onItemClick, ItemSelected, PageSelected, etc.) during compilation, only supporting click data collection. Touch, swipe, and other operations are not currently supported.
3. No crashes collected or fewer crashes collected than expected.
- The Tingyun SDK has supported Native Crash exception collection since version 2.11.1. Previous versions only collected Java Crashes.
- Crashes that occur before Tingyun SDK initialization cannot be collected.
- Check if the crash collection switch is enabled in the report.
- If the application has its own exception handling or third-party crash collection logic, it must be initialized before the Tingyun SDK.
4. TCP, SSL, and other metric data showing 0.
- The Tingyun SDK must be initialized before the application's own network requests are initiated
- Android 8.1 and above only support OkHttp3 TCP, SSL, and other metric data collection
- TCP data cannot be collected when using HTTP proxy.
- WebView cross-origin resource response headers are not configured with Timing-Allow-Origin: *
5. WebView data not collected or only network errors and HTTP errors collected.
- NBSWebChromeClient.initJSMonitor(view, newProgress) is not called in the onProgressChanged method of WebChromeClient.
- SPA single-page application data collection is not supported.
- Data collection for HTML code loaded using loadDataWithBaseURL is not supported.
6. URL filtering and error filtering not taking effect.
Check if the configuration in the report is correct. You can use online regex tools to verify. Note that slashes "/" need to be added before and after the regex configuration in the report.
7. If the project uses MultiDex packaging, Android 5.0 and below devices may experience java.lang.NoClassDefFoundError exceptions.
The classes causing errors need to be allocated to the main dex. You can refer to the solution provided by Google.
8. Sophix patch tool fails to generate patches.
The Tingyun SDK instruments the attachBaseContext() and onCreate() methods of the Application class during compilation to collect application startup data. However, since version 3.2.1, Alibaba's Hotfix patch tool requires that no non-Android official APIs be called before initialize, causing patch generation to fail.
【Solution】
To pass the patch tool's checks, Tingyun cannot instrument the Application class during compilation. You can filter the Application class in the Tingyun tingyun.properties configuration file. This will affect Tingyun's collection of application startup data, so manual instrumentation of the Application class is required.
- In the tingyun.properties configuration file (create if it doesn't exist, with one copy in the project root directory and one in the main module), configure filtering for Alibaba's Application class and the project's own RealApplication class:
# After the equals sign is the complete class name, with dots replaced by slashes, multiple class names separated by commas
# com/nbs/app/MyApp is an example, replace with the project's real Application class
noInstrumentedClasses=com/nbs/app/SophixStubApplication,com/nbs/app/MyApp
- 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:
- After hot patching, test whether Tingyun can start normally on Android 9+ devices. Check if the NBSAgent "connect success" log is printed. If it doesn't start normally, add the following class to the whitelist in Alibaba's patch tool:
com.networkbench.agent.impl.NBSAgent
- After hot patching, test whether Tingyun can collect crashes. Since Alibaba registers CrashHandler twice at startup and 3 seconds after startup, but only obtains defaultHandler at startup, if the application crashes 3 seconds after startup, Alibaba will skip the previously registered third-party CrashHandler and throw directly to the system, preventing third parties from collecting crashes. Contact Alibaba to modify their CrashHandler logic.
【Reference】
For Hotfix patch tool error troubleshooting steps, see Alibaba Cloud's introduction.
9. java.util.zip.ZipException occurs during compilation.
SDK jar package is referenced multiple times. Check the libs directory and build.gradle file to ensure only one copy of nbs.newlens.agent.jar is referenced.
10. Compilation fails when the project uses Lambda.
Place the Tingyun plugin after lambda:
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'newlens'
11. SDK compilation time issues.
The principle of the Tingyun SDK is bytecode instrumentation (using Transform API), which to some extent affects project compilation time. We provide a configuration where the Tingyun SDK does not participate in compilation during development. If your project is large and you notice a significant increase in compilation time after integrating the Tingyun 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 not instrument the project. Must be set to true before submitting for testing and release
}
12. Multiple dids appear for the same device in the report
Since version 2.14.2, the Tingyun SDK no longer collects IMEI and other device information. The did is issued by the server on first application launch and cached locally. If the application is uninstalled and reinstalled during testing, or if "Clear Data" is performed on the application, the locally cached did will be cleared, and a new did will be issued when the application is launched again.
13. Cannot add process attribute to the application in AndroidManifest.xml file
Since version 2.14.2, the Tingyun SDK no longer collects IMEI and other device information. The did is issued by the server on first application launch and cached locally. To prevent multiple processes from being initialized concurrently and issuing different dids, the SDK restricts multi-process initialization. If no did cache exists locally, child processes will not initialize. The SDK compares package name and process name when determining processes. If a process attribute is added to the application, the SDK may stop collecting data.
14. How to pass custom business data to BPI
Use "Custom Operations" to define a [Business Operation] to understand its performance. This interface data is only displayed in BPI reports.
- Related interface
Note: The "Custom Operation" interface needs to be called in pairs. actionName cannot be empty and supports cross-method, cross-thread calls.
customActionStart(String actionName);
customActionEnd(String actionName, String tag, Map cust);
- Code example
private void login() {
NBSAppAgent.customActionStart("login");
// ... business logic
Map cust = new HashMap();
cust.put("userName","abc");
NBSAppAgent.customActionEnd("login","tag",cust);
}
15. Cannot connect to server when initializing SDK with HTTP
The SDK uploads data via HTTPS by default. If the server only supports HTTP, set "setHttpEnabled(true)". Android 9.0 and above restrict HTTP requests, which can be resolved by adding network_security_config.xml configuration.
Create an xml directory under res, then create a 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"
...
/>