IMQA GUIDE
HomepageFAQDeveloper forum
ENG
ENG
  • Getting started
    • Notice
    • Supported environment
  • Installation Guide
    • Android
      • Installing MPM SDK
      • Setting MPM SDK
      • Installing Crash SDK
      • Setting Crash SDK
    • iOS
      • Installing MPM SDK
      • Setting MPM SDK
      • Installing Crash SDK
      • Setting Crash SDK
    • React Native
      • Android
      • iOS
      • React Native Library
    • Cordova
      • Android
      • iOS
    • Morpheus
      • Android
      • iOS
    • W Hybrid
    • Web (WPM)
      • WebAgent Installation
      • WebAgent Setting
      • Browser Compatibility
  • User Guide
    • Using MPM
      • Project list
      • Performance Dashboard
      • A/B Dashboard
      • Screen performance analysis
      • Detailed performance analysis
      • UBA (User Behavior Analysis)
      • Region analysis
      • Statistics
      • Report
      • Alert
      • Management
    • Using Crash
      • Project list
      • Dashboard
      • Error details
      • Error search
      • Statistics
      • Settings
    • Using WPM
      • Project list
      • Performance Dashboard
      • Page performance analysis
      • Detailed performance analysis
      • Reverse Behavior Analysis
      • Statistics
      • Report
      • Alert
      • Management
    • Using WCrash
      • Project list
      • Dashboard
      • Error details
      • Error search
      • Statistics
Powered by GitBook
On this page
  • 1. Add injector to build.gradle in project
  • 2. Add the library to your app’s gradle
  • 3. Add ImqaBridge to each WebView object created
  • Register WebView Agent
  1. Installation Guide
  2. Morpheus

Android

Install SDK in Morpheus Environment

This document provides instructions on how to apply IMQA SDK in the React Native environment.

After applying the IMQA agent code with reference to the IMQA MPM Installation Guide, please follow further the instructions of this document.

1. Add injector to build.gradle in project

After adding injector to your project’s build.gradle, add the library and ImqaBridge to your app’s gradle as shown below.

Do not apply the plugin – different from the previous guide.

The gradle file should be synchronized after updating the file.

build.gradle
buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1' 
			  // Gradle Tools Suitable for Client Environment
        ....
        classpath 'io.imqa:imqa-mpm-injector:2.25.6'

    }
}

2. Add the library to your app’s gradle

AndroidManifest.xml
//apply plugin: 'io.imqa'
//Do not apply the plugin – different from the previous guide.

dependencies {
    ...
    implementation 'io.imqa:imqa-core:2.27.5'
    implementation 'io.imqa:imqa-mpm-client:2.27.9'
    implementation 'io.imqa:imqa-crash-client:2.27.5'
		//Add the Latest IMQA SDK
}

//Add the following code under dependency
io.imqa.IMQAPlugin imqaPlugin = new io.imqa.IMQAPlugin()
imqaPlugin.init(project)
new io.imqa.injector.GJavacAction(project.name).setConfiguration(project)
android.applicationVariants.all { variant ->
    variant.javaCompile.doLast { task ->
        new io.imqa.injector.CompileAction(
                io.imqa.injector.util.BuildOption.BUILD_LOCATION_TYPE.javacClasses,
                project.name,
                io.imqa.injector.GJavacAction.convertBuildType(variant.getBuildType()),
                io.imqa.injector.GJavacAction.makeFlavor(variant.getBuildType().name,
                        variant)
        ).execute(task)
    }
}

3. Add ImqaBridge to each WebView object created

How to add IMQABridge may vary depending on development using Morpheus.

Example of adding ImqaBridge to a WebView object
mWebView.addJavascriptInterface(new AndroidBridge(), AndroidBridge.KEY_NAME);
.
.
.
io.imqa.mpm.network.webview.WebviewInterface imqaJavascript = new
        io.imqa.mpm.network.webview.WebviewInterface();
mWebView.addJavascriptInterface(imqaJavascript, "ImqaBridge");
Example of adding ImqaBridge to a WebView object hidden in the inheritance structure
getWebView().getSettings().setJavaScriptEnabled(true);
io.imqa.mpm.network.webview.WebviewInterface imqaJavascript = new
		io.imqa.mpm.network.webview.WebviewInterface();
getWebView().addJavascriptInterface(imqaJavascript, "ImqaBridge");

Register WebView Agent

Morpheus drops static files inside the mobile instead of fetching mobile pages from the server. Place the WebView agent for Morpheus we provide at the top of the head on all pages. Due to the structure of Morpheus, we recommend not using cdn but injecting the resources by yourself.

Last updated 1 year ago