Installing Crash SDK

If you add IMQA Crash to an Android project, you can check the performance issues of the application, which occur in the app developed with Java or Kotlin, in various viewpoints.

This is not required for Android if you have already installed the MPM.

Please install Crash SDK after creating an iOS project at the IMQA project page and receiving the project key.

1. Installing the SDK

Generally, it can be found in “<project_dir> /app/build.gradle”.

• Open the “app.gradle” file in Android Studio. • Add “mavenCentral()” to the repositories. • Add “imqa-crash-client” to the dependencies.

The gradle file should be synchronized after updating the file.

app.gradle
// Add jcenter repository
repositories {
    mavenCentral()
}

// Add compile or implementation dependencies
dependencies {
    compile 'io.imqa:imqa-core:2.27.4'
    compile 'io.imqa:imqa-crash-client:2.27.4'

    // Add when using zstd
    implementation 'com.github.luben:zstd-jni:1.5.2-3@aar'
}

2. Basic setting

Internet setting

Add Internet authority to the “AndroidManifest.xml” project to upload occurred crash information.

AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<!-- To view the LogCat contents -->
<uses-permission android:name="android.permission.READ_LOGS"/> 

Initializing IMQAController

Insert codes that initialize IMQAController into the “Application” class of the project. You can receive PROJECT_KEY after creating a project on the IMQA website.

MyApplication.java
...
  @Override
  public void onCreate() {
      super.onCreate();
      io.imqa.crash.IMQACrashAgent.InitializeAndStartSession(
          this,
          BuildConfig.FLAVOR,
          "PROJECT_KEY");
  }
...
MyApplication.kt
...
  override fun onCreate() {
      super.onCreate()
      io.imqa.crash.IMQACrashAgent.InitializeAndStartSession(
          this,
          BuildConfig.FLAVOR,
          "PROJECT_KEY")
  }
...

⚠️ HTTPS (API level > 27)

The HTTPS request is required from Android API level 28 and above due to the enhanced network security policy. The following measures are needed to meet the requirement:

  1. Authenticated HTTPS request Request authenticated HTTPS to the IMQA server to collect the data normally.

MyApplication.java or MyApplication.kt
...
imqaOption.setServerUrl('https://collector.imqa.io');
...
  1. Forced HTTP request You can allow all cleartext HTTP traffic by setting this flag.

AndroidManifest.xml
...
<application
    ...
    android:usesCleartextTraffic="true"
    />
...

Using Zstandard (Zstd)

You can use Zstandard, which is an algorithm enabling more secure and efficient data compression, instead of the typical gzip. To use it, you need the following settings:

• Setting the MPM Mode Option You can set whether to use Zstd in the settings when inserting the IMQA startup code.

MyApplication.java or MyApplication.kt
...
imqaOption.setCompressZstd(true);
...

• Add Zstd Library In the “app.gradle” file, add the “zstd-jni” aar library to the “dependencies” block in “buildscript”.

app.gradle(app module)
...
    dependencies {
    // Add dependencies.
       ...
       implementation 'com.github.luben:zstd-jni:1.5.2-3@aar'
       ...
    } 
} 

3. ProGuard setting

ProGuard is a tool used to make the APK as small as possible in size by removing unused resources and shortening the name of classes or methods. When using ProGuard or DexGuard, the original class and method name can be displayed on the crash report by uploading the mapping file as below:

Preparation

If ProGuard is used in a project under development, the source code is obfuscated, making the analysis difficult. In this case, obfuscated codes can be analyzed using the generated mapping.txt file. Add the following to ProGuard rules (proguard-rules.pro):

proguard-rules.pro
  -keepattributes SourceFile,LineNumberTable
  -printmapping map.txt

  # IMQA Proguard
  -keep class io.imqa.** { *; }
  -dontwarn io.imqa.**

  # okhttp3 Proguard
  -dontwarn okhttp3.**
  -dontwarn okio.**p

A file is created in the app/build/outputs/mapping/debug (or release)/mapping.txt directory. (The file location may differ a little depending on the buildType and flavor.) You need to connect to http://crash.imqa.io to upload the file created in this way.

When uploading the file, its name must be named as “mapping.txt” or “map.txt”.

Upload process

1. Select “Setting” at the project menu.

2. Click the [File Upload] button to open the upload window.

3. Click the [Choose File] button that matches the app version specified in the gradle and upload the “mapping.txt” file.

4. If you click the [Upload] button, the crash information collected afterwards will be displayed after analysis.

When the latest version of the app is released, please register additional mapping files of the same app version in order to view the version’s crash information.

4. Settings required for the installation-type

Any client who selects an IMQA installation-type must set the collection server.

MyApplication.java
@Override
public void onCreate() {
    super.onCreate();
    io.imqa.core.IMQAOption imqaOption = new io.imqa.core.IMQAOption();

    /*
     * Default value : 'https://collector.imqa.io'
     * String : Server information
     */
    imqaOption.setCrashServerUrl('https://(ipaddress)');

    io.imqa.crash.IMQACrashAgent.InitializeAndStartSession(
        this, // Application Context
        BuildConfig.FLAVOR, // Project Flavor Setting
        "PROJECT_KEY",  // Issued project key
        imqaOption // Add an object when the option is set
    );
}

Last updated