2. Mobile Explorer Agent Integration for Android using Eclipse IDE

Notes: if you are developing mobile application that target Android 6 or later that integrates with Mobile Explorer Agent, make sure you enable app permissions on Android 6.0+ devices when deploying your application to that Android device.

This section will show you how to integrate qTest Mobile Explorer Agent with your application on Android devices in Eclipse.

These are the steps that you need to follow:

Required Environment

Currently, we only support the following environments

Check all required components to install and click Finish.

Step 1: Download Mobile Explorer Agent

In the first step, you need to download the Mobile Explorer Agent from HERE

 

Step 2: Add Mobile Explorer Agent to your project

  • Extract “Mobile_eXplorer_Agent_Eclipse.zip” archive file. You will get Mobile_eXplorer_Agent_Eclipse folder.
  • Import AGENT to eclipse workspace:
    • Click File/Import… -> A popup window will show.

    • Choose "Existing Android Code to Workspace" and press Next -> Explore to choose Mobile_Explorer_Agent_Eclipse folder -> OK

    • Press Finish to complete import Mobile_eXplorer_Agent_Eclipse.
    • You can see Mobile_eXplorer_Agent_Eclipse in Package Explorer panel.
  • Convert your project to AspectJ project:
    • Right click on your project, choose Configure -> Convert to AspectJ Project

  • Add Mobile Explorer as your library project:
    • Right click on project and choose Properties. A popup window will show:

    • Choose Android in left panel -> press Add… button

    • Choose Mobile_eXplorer_Agent_Eclipse in popup window and press OK.
    • Choose AspectJ Build in left panel

    • Press Add JARs… button. It will show:

    • Select mexplorer_agent.jar in Mobile_eXplorer_Agent_Eclipse/libs -> OK

    • Choose Java Build Path in left panel Order and Export. Check on AspectJ Library Runtime.

  • Modify AndroidManifest.xml
    • Open [Your project]/AndroidManifest.xml file.
    • Add this code to manifest tag to provide permissions of Mobile Explorer. If there is duplicate permission in your AndroidManifest.xml file, please remove it to make each permission unique.
      <!--Mobile eXplorer Permissions-->
       <uses-permission android:name="android.permission.INTERNET"/>
       <uses-permission android:name="android.permission.GET_TASKS"/>
       <uses-permission android:name="android.permission.GET_TOP_ACTIVITY_INFO"/>
       <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
       <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
       <uses-permission android:name="android.permission.RECORD_AUDIO"/>
       <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
       <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
       <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
       <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
       
       <uses-feature android:name="android.hardware.camera"/>
      
    • Add this code to application tag
      
       <uses-library
           android:name="org.apache.http.legacy"
           android:required="false" />
          
      <!-- import Mobile Explorer Service -->
       <service
           android:name="com.qas.mexplorer.service.MXService"
           android:exported="true"/>
       
       <!-- import Mobile Explorer Activities -->
        <activity
           android:name="com.qas.mexplorer.app.MXSettingAlwaysOnProjectActivity"
           android:configChanges="keyboardHidden|orientation|screenSize"
           android:theme="@style/MXTheme.Dark"/>
       <activity
           android:name="com.qas.mexplorer.app.MXSettingsActivity"
           android:configChanges="keyboardHidden|orientation|screenSize"
           android:theme="@style/MXTheme.Dark"/>
       <activity
           android:name="com.qas.mexplorer.app.MXInformationActivity"
           android:configChanges="keyboardHidden|orientation|screenSize"
           android:theme="@style/MXTheme.Dark"/>
       <activity
           android:name="com.qas.mexplorer.app.MXFlashActivity"
           android:configChanges="keyboardHidden|orientation|screenSize"
           android:theme="@style/MXTheme.Dark"/>
       
       <activity
           android:name="com.qas.mexplorer.app.MXCreateSessionActivity"
           android:configChanges="keyboardHidden|orientation|screenSize"
           android:theme="@style/MXTheme.Dark"/>
       <activity
           android:name="com.qas.mexplorer.editor.MXEditorActivity"
           android:configChanges="keyboardHidden|orientation|screenSize"
           android:theme="@style/MXTheme.Dark"
           android:windowSoftInputMode="stateUnchanged|adjustPan"/>
      <activity
           android:name="com.qas.mexplorer.editor.view.MXPieChartActivity"
           android:configChanges="keyboardHidden|orientation|screenSize"
           android:theme="@style/MXTheme.Dark"/>
       <activity
           android:name="com.qas.mexplorer.editor.gallery.MXCustomGalleryActivity"
           android:screenOrientation="portrait"
           android:theme="@style/MXTheme.Dark">
           <intent-filter>
               <action android:name="luminous.ACTION_PICK"/>
               <action android:name="luminous.ACTION_MULTIPLE_PICK"/>
       
               <category android:name="android.intent.category.DEFAULT"/>
           </intent-filter>
       </activity>
      
    • If your app support for Android version below 14 please change it to 14.

      Example:

      <uses-sdk
           android:minSdkVersion="14"
           android:targetSdkVersion="19"/>
      

       

      Example: My AndroidManifest.xml in my test project looks like following:

      <?xml version="1.0" encoding="utf-8"?>
       <manifest
           package="com.qas.testapp.mexplorer"
           xmlns:android="http://schemas.android.com/apk/res/android">
       
           <!--Mobile eXplorer Permissions-->
           <uses-permission android:name="android.permission.INTERNET"/>
           <uses-permission android:name="android.permission.GET_TASKS"/>
           <uses-permission android:name="android.permission.GET_TOP_ACTIVITY_INFO"/>
           <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
           <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
           <uses-permission android:name="android.permission.RECORD_AUDIO"/>
           <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
           <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
           <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
       
           <!--Mobile eXplorer Features-->
           <uses-feature android:name="android.hardware.camera"/>
       
           <application
               android:allowBackup="true"
               android:icon="@drawable/ic_launcher"
               android:label="@string/app_name"
               android:theme="@style/AppTheme">
      	 <uses-library 
      android:name="org.apache.http.legacy" android:required="false" /> <activity android:name=".ItemListActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name=".ItemDetailActivity" android:label="@string/title_item_detail" android:parentActivityName=".ItemListActivity"> <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".ItemListActivity"/> </activity> <!-- import Mobile Explorer service --> <service android:name="com.qas.mexplorer.service.MXService" android:exported="true"/> <!-- import Mobile Explorer Activities --> <activity android:name="com.qas.mexplorer.app.MXSettingAlwaysOnProjectActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@style/MXTheme.Dark"/> <activity android:name="com.qas.mexplorer.app.MXSettingsActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@style/MXTheme.Dark"/> <activity android:name="com.qas.mexplorer.app.MXInformationActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@style/MXTheme.Dark"/> <activity android:name="com.qas.mexplorer.app.MXFlashActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@style/MXTheme.Dark"/> <activity android:name="com.qas.mexplorer.app.MXCreateSessionActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@style/MXTheme.Dark"/> <activity android:name="com.qas.mexplorer.editor.MXEditorActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@style/MXTheme.Dark" android:windowSoftInputMode="stateUnchanged|adjustPan"/> <activity android:name="com.qas.mexplorer.editor.view.MXPieChartActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@style/MXTheme.Dark"/> <activity android:name="com.qas.mexplorer.editor.gallery.MXCustomGalleryActivity" android:screenOrientation="portrait" android:theme="@style/MXTheme.Dark"> <intent-filter> <action android:name="luminous.ACTION_PICK"/> <action android:name="luminous.ACTION_MULTIPLE_PICK"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity> </application> </manifest>
  • Set NDK location
    • Open Eclipse Preferences. On Mac Choose Eclipse -> Preferences

    • Choose Android -> NDK -> if you does not set NDK location click to Browse… button -> Select NDK folder in your local drive, otherwise skip this step.

 

Step 3: Enable Mobile Explorer Agent on your app

  • Copy and change Mobile Explorer configuration
    • Copy all files in Mobile_eXplorer_Agent_Eclipse/assets to [Your Project]/assets folder. If your project does not have assets folder, you have to create it.

  • Configure Mobile Explorer Settings
    • Open mexplorer_config.properties. This file is located in [Your Project]/assets/mexplorer_config.properties. Change this file like this code:
      QTEST_HOST=[Provide qTest Link]
      QTEST_DEFAULT_USER_NAME=[Provide qTest Default Account]
      QTEST_DEFAULT_PASSWORD=[Provide qTest Default Password]
      THEME=[dark/light]
      

      Example: The configuration below we using in beta site:

      QTEST_HOST=https://beta-mexplorerdemo.qtestnet.com
      QTEST_DEFAULT_USER_NAME=mexplorer_demo@mailinator.com
      QTEST_DEFAULT_PASSWORD=admin123
      THEME=dark
      

       

Step 4: Build and Release your application

Now you finish integrating Mobile Explorer into your testing application, please build and run.