Skip to content

Troubleshooting

Compilation Troubleshooting

If an error occurs during the compilation process, the compilation environment should be checked first.

Runnable Compilation Environment

✅ Runnable Environment

  • AGP com.android.tools.build:gradle version 3.5.0 or above
  • Gradle version 5.4.0 or above
  • Java version 8.0 or above
  • Android minSdkVersion 21

Note: As the Android Studio version updates, the compatibility of these versions will also change. If you encounter compilation errors despite meeting the above conditions, please contact our developers.

⚠️ Compatible Runtime Environment

  • AGP com.android.tools.build:gradle version 3.0.1 or above
  • Gradle version 4.8.1 or above
  • Java version 8.0 or above
  • Android minSdkVersion 21

In this environment, ft-plugin cannot be used, and the automatic data capture part needs to be manually integrated. For more information on manual integration, refer to here.

SDK Cannot Resolve Import

The above errors occur because the maven repository is not set correctly. Please refer to the configuration here.

Compilation Errors

Desugaring Error

>Task :app:transformClassesWithStackFramesFixerForDebug
    Exception in thread "main" java.lang.IllegalStateException: Expected a load for Ljava/lang/String; to set up parameter 0 for com/ft/sdk/FTRUMGlobalManager$$Lambda$11 but got 95
        at com.google.common.base.Preconditions.checkState (Preconditions.java:756)
        at com.google.devtools.build. android.desugar.LambdaDesugaring$InvokedynamicRewriter .attemptAllocationBeforeArgumentLoadsLambdaDesugaring.java:535)
        at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitInvokeDynamicInsn
        (LambdaDesugaring.java: 420)
        at org.objectweb.asm.ClassReader.a(Unknown Source)
        at org.objectweb.asm.ClassReader.b(Unknown Source)
        at org.objectweb.asm.ClassReader.accept(Unknown Source)
        at org.objectweb.asm.ClassReader.accept(Unknown Source)
        at com.google.devtools.build. android.desugar. Desugar.desugarClassesInInput (Desugar.java:401) at com.google.devtools.build.android.desugar.Desugar.desugar0neInput(Desugar.java:326) at com.google.devtools.build.android.desugar. Desugar.desugar (Desugar.java:280) at com.google.devtools.build.android.desugar. Desugar.main (Desugar.java:584)
If the above error occurs during compilation, it is due to compatibility issues with AGP 3.0.0. This issue explains the problem. You can resolve it by upgrading AGP to 3.1.0 or above, or by using a newer version of the SDK. Upgrade the version in app/build.gradle as follows:

dependencies {
    implementation('com.cloudcare.ft.mobile.sdk.tracker.agent:ft-sdk:1.3.10.beta01')//1.3.10 or above
}

API 'android.registerTransform' is obsolete

Transform has been marked as Deprecated in AGP 7.0 and has been removed in AGP 8.0. ft-plugin:1.2.0 has been adapted to this change. Please upgrade to the corresponding version to fix this error. For specific instructions, refer to Integration Configuration

AndroidComponentsExtension ClassNotFoundException

AndroidComponentsExtension is a method supported by AGP 7.4.2. If your compilation environment is below this version, this error will occur. You can use the ft-plugin-legacy version to fix this error. For specific instructions, refer to Integration Configuration

java.lang.IllegalArgumentException:

  • Invalid opcode 169

If this error occurs while using ft_plugin_legacy, it is due to a bug in asm-commons:7.0. The original issue is here. You can resolve this by depending on org.ow2.asm:asm-commons:7.2 or above in the plugin configuration. Use ./gradlew buildEnvironment to confirm the actual asm-commons version being used.

buildscript {
    dependencies {
        classpath 'com.cloudcare.ft.mobile.sdk.tracker.plugin:ft-plugin-legacy:[version]'
        // Add dependency
        classpath 'org.ow2.asm:asm-commons:7.2' 
    }
}
  • org.ow2.asm:asm version below 7.0

The current plugin version only supports build environments using org.ow2.asm:asm7.x or above. Use ./gradlew buildEnvironment to query the build environment and confirm this issue. You can fix this by forcibly depending on version 7.x or above, preferably version 7.2 or above.

buildscript {
    dependencies {
        classpath 'com.cloudcare.ft.mobile.sdk.tracker.plugin:ft-plugin-legacy:[version]'
         // Add dependency
        classpath 'org.ow2.asm:asm:7.2'
        classpath 'org.ow2.asm:asm-commons:7.2'
    }
}

SDK Initialization Exception Verification

Check Logcat to see if there are any logs with Level as Error and Tag prefixed with [FT-SDK].

[FT-SDK] com.demo E Please install the SDK first (call FTSdk.install(FTSDKConfig ftSdkConfig) when the application starts)

Enabling Debug Mode

ft-sdk Debug Mode

You can enable the SDK's debug function with the following configuration. Once enabled, the SDK debug logs will be output to the console LogCat. You can filter the [FT-SDK] characters to locate the TrueWatch SDK logs.

  val config = FTSDKConfig.builder(datakitUrl).setDebug(true)
  FTSdk.install(config)

Log Examples

Data Synchronization
//Check if the upload address is correctly entered into the SDK configuration
[FT-SDK]FTHttpConfigManager com.demo D  serverUrl ==>
                                    Datakit Url:http://10.0.0.1:9529
//The following are connection error logs
[FT-SDK]SyncTaskManager com.demo   E  Network not available Stop poll
[FT-SDK]SyncTaskManager com.demo   E  
            1:Sync Fail-[code:10003,response:failed to connect to 10.0.0.1 (port 9529) from 
            10.0.2.16 (port 47968) after 10000ms, check if the local network connection is normal]

//The following are normal synchronization logs
[FT-SDK]SyncTaskManager com.demo   D  Sync Success-[code:200,response:]

It is recommended to disable this configuration when releasing the Release version

ft-plugin Debug Mode

You can enable the Plugin's debug logs with the following configuration. Once enabled, you can find the [FT-Plugin] output logs in the Build output logs. Use this to check the Plugin ASM write status.

FTExt {
    //Whether to show Plugin logs, default is false
    showLog = true
}

It is recommended to disable this configuration when releasing the Release version

SDK Internal Logs Converted to Cache Files

// >= 1.4.6
// Default path: /data/data/{package_name}/files/LogInner.log
LogUtils.registerInnerLogCacheToFile()

// >= 1.4.5+ 
val cacheFile = File(filesDir, "LogCache.log")
LogUtils.registerInnerLogCacheToFile(cacheFile)

To ensure the integrity of internal logs, this configuration should be set before SDK initialization

SDK Runs Normally but No Data

  • Check if Datakit is running normally

  • Confirm that the SDK upload address datakitUrl or datawayUrl is configured correctly and initialized correctly. In debug mode, check the logs to determine the upload issue.

  • Check if datakit is uploading data to the corresponding workspace and if it is offline. This can be confirmed by logging into TrueWatch and checking the "Infrastructure" section.

Compatibility Issues with OKhttp 3.12.+

ft-sdk < 1.6.13, if data compression FTSDKConfig.setCompressIntakeRequests(true) is enabled, you may find that the SDK collects data successfully, but no error prompts or http code logs are printed during data synchronization.

Solution: Use ft-sdk >= 1.6.13 or okhttp 4.5.0 or above to resolve this issue.

Data Loss

Partial Data Loss

  • If some Session data in RUM or a few Log or Trace data are lost, first check if sampleRate < 1 is set in FTRUMConfig, FTLoggerConfig, FTTraceConfig.
  • Check the network of the device uploading data and the network and load of the device where datakit is installed.
  • Confirm that FTSdk.shutDown is called correctly. This method releases the SDK data processing objects, including cached data.

Resource Data Loss

Automatic Collection, ft-plugin Not Integrated Correctly

Resource automatic collection requires Plugin ASM bytecode writing to automatically set OkHttpClient Interceptor and EventListener, and write FTTraceInterceptor, FTResourceInterceptor, FTResourceEventListener.FTFactory. If Plugin is not used, refer to here

OkHttpClient.build() ASM Writing Issue

Plugin ASM automatically injects network collection functionality when the application calls OkHttpClient.Builder().build(). The following two situations may cause network collection to fail: 1. Timing issue - SDK initialization is not complete. If OkHttpClient.Builder().build() is called before SDK initialization is complete, it will load an empty configuration, resulting in the loss of Resource-related data. Check the debug logs to confirm if the initialization order is correct. 2. Creation method issue. The standard OkHttpClient.Builder().build() method is not used to create the OkHttpClient object, such as directly instantiating OkHttpClient or using other construction methods.

//SDK initialization logs
[FT-SDK]FTSdk   com.ft  D  initFTConfig complete
[FT-SDK]FTSdk   com.ft  D  initLogWithConfig complete
[FT-SDK]FTSdk   com.ft  D  initRUMWithConfig complete
[FT-SDK]FTSdk   com.ft  D  initTraceWithConfig complete

//Logs printed when SDK OkHttpClient.Builder.build() is called
//(should be called after SDK initialization)
[FT-SDK]AutoTrack   com.ft  D  trackOkHttpBuilder    

If the initialization call order cannot be adjusted, choose manual integration

Data is Reprocessed Using Interceptor or EventListener

After Plugin ASM is inserted, addInterceptor will be added to OkHttpClient.Builder() in the original project code, and FTTraceInterceptor and FTResourceInterceptor will be added. The body contentLength in the http request will be used to calculate a unique id, and the Resource data at each stage will be connected through this id. Therefore, if the integrator also adds addInterceptor when using Okhttp and reprocesses the data, causing its size to change, the id calculation at each stage will be inconsistent, resulting in data loss.

Solution:

  • ft-sdk < 1.4.1

    By customizing the addInterceptor position order, let the SDK method calculate the id first to solve this problem. To avoid duplicate settings, the custom method needs to disable FTRUMConfig's enableTraceUserResource and FTTraceConfig's enableAutoTrace configurations.

  • ft-sdk >= 1.4.1

    The SDK automatically adapts to this issue in non-manual settings. If manual settings have been made, ensure that Interceptor is in a forward position.

Compatibility Issues with OKhttp 3.12.+

ft-sdk < 1.6.13 If the Interceptor used reads the response body content for read, it may cause the current Resource data to be uncollectable.

Solution:

  • ft-sdk < 1.6.13

    • Without changing the Okhttp version, manually set to resolve this issue

    OkHttpClient.Builder builder = new OkHttpClient.Builder()
        .addInterceptor(new CustomReadReponseInterceptor())//Read response body
        .addInterceptor(new FTTraceInterceptor())
        .addInterceptor(new FTResourceInterceptor())
        .addInterceptor(new CustomRequestBodyFixInterceptor())//Encrypt or modify body
        .eventListenerFactory(new FTResourceEventListener.FTFactory());
    
    OkHttpClient client = builder.build();
    
    * Upgrading Okhttp to 4.5.0 or above can also resolve this issue. * ft-sdk >= 1.6.13

    The SDK automatically adapts to this issue in non-manual settings.

Error Data Loss Crash Type Data

  • Confirm if other third-party SDKs with Crash capture functionality are also used. If so, place the SDK initialization method after other SDKs.

Missing Field Information in Data

User Data Field

  • Confirm that the user data binding method is called correctly. In debug mode, you can track this issue through logs.

    [FT-SDK]FTRUMConfigManager com.demo D  bindUserData xxxx
    
    ///---> Your data operations <-----
    
    [FT-SDK]FTRUMConfigManager com.demo D unbindUserData
    

Missing Custom Parameters or Incorrect Values

  • Confirm that FTRUMConfig.addGlobalContext, FTLoggerConfig.addGlobalContext are called in the correct scenarios. These are suitable for data that does not change during an application cycle, such as application channel providers, different Flavor attributes, etc. If dynamic scenarios require real-time response, use manual calls to RUM and Log interfaces.
  • In debug mode, check the [FT-SDK]SyncTaskManager logs to verify the correctness of custom field parameters.

Lag Issues When enableConsoleLog is Enabled

If lag occurs, it may be due to excessive log collection data. The principle of FTLoggerConfig.enableConsoleLog is to capture android.util.Log, Java, and Kotlin println. It is recommended to adjust FTLoggerConfig configuration parameters such as sampleRate, logPrefix, logLevelFilters as needed to eliminate or alleviate this issue.

Okhttp EventListener Fails After Integrating SDK

After Plugin AOP ASM is inserted, eventListenerFactory will be added to OkHttpClient.Builder() in the original project code, which will overwrite the original eventListener or eventListenerFactory.

Solution:

  • ft-sdk < 1.4.1

    Disable the automatic Plugin AOP setting FTRUMConfig setEnableTraceUserResource(false), and customize a CustomEventListenerFactory inheriting FTResourceEventListener.FTFactory, and use custom integration.

  • ft-sdk >= 1.4.1

    Customize a CustomEventListenerFactory inheriting FTResourceEventListener.FTFactory, and customize the ASM-written eventListenerFactory by setting FTRUMConfig.setOkHttpEventListenerHandler.

  • ft-sdk >= 1.6.7

    The SDK automatically adapts to this issue in non-manual settings.

TraceID Missing or Not Matching Trace Propagation Header

When collecting complete request data, information usually needs to be obtained from Interceptor and EventListener separately. To effectively associate these two parts of data, the SDK needs a unique ID to connect the same network request. However, before version 1.6.10, this ID was the same in the same request, which could cause data confusion or loss in high concurrency scenarios. Starting from version 1.6.10, you can call FTSDKConfig.setEnableOkhttpRequestTag(true) or explicitly add ResourceID to the Request to distinguish unique identifiers for each request, avoiding interference between the same requests. For setup instructions, refer to here