Quick Start

Requirements

  • Android OS version: v5.0 (API v21) or higher.
  • compileSdkVersion: 34
  • targetSdkVersion: 34
  • Kotlin: 1.8.10 or higher.
  • Android SDK download size ~ 57.5 MB

Important❗

The Metamap SDK uses libraries and in order to avoid any potential production crashes you should use the same versions of the libraries if they exist in your project. The list of the libraries used by each version of MetaMap SDK can be found in the Maven POM File here.

Setup

In your root-level (project-level) Gradle file (/build.gradle),

  • add the reference to the following repository:

      buildscript {
        //..
        repositories {
            //..
            mavenCentral()
        }
      }
    

The current version of our SDK also requires jitpack to be included as part of the available repositories due to internal dependencies:

  buildscript {
    //..
    repositories {
        //..
          maven { url "https://jitpack.io" }
    }
  }

In your module (app-level) Gradle file (usually //build.gradle)

  • enable Java 11 source compatibility.

    android {
      //..
      compileOptions {
    		sourceCompatibility = JavaVersion.VERSION_11
    		targetCompatibility = JavaVersion.VERSION_11
      }
      kotlinOptions {
        jvmTarget = JavaVersion.VERSION_11.toString()
      }
      //..
    }
    
  • add the dependencies

    dependencies {
      //...
    	implementation ('com.metamap:android-sdk:3.42.1')
    }
    

Then sync your project with the gradle files.

Go to your Activity simply call MetamapSdk.startFlow(...)

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main);
        //..

        MetamapSdk.startFlow(this,"YOUR_CLIENT_ID", "YOUR_FLOW_ID")
    }
}
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //..
        MetamapSdk.INSTANCE.createFlowIntent(this,"YOUR_CLIENT_ID", "YOUR_FLOW_ID", null, null);
    }
}

In order to make this work you need to set your own CLIENT_ID and FLOW_ID. You can find them in the Metamap Dashboard, for more details please check this section.

Troubleshooting

Attribute application@allowBackup value=(true) from AndroidManifest.xml

Attribute application@allowBackup value=(true) from AndroidManifest.xml is also present at [com.metamap:android-sdk:3.42.1] AndroidManifest.xml value=(false). Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml to override.

Solution

This means that you have set allowBackup in your AndroidManifest.xml to true, but the Metamap SDK has this value set to false. Having allowBackup set to true is a potential security issue, so we suggest setting it to false. If you are sure that you wish to allow backups, then add tools:replace="android:allowBackup" to <application> element in your AndroidManifest.xml. If you already have some attributes in tools:replace, separate them with commas (for example: "android:label,android:allowBackup").


What’s Next

Now we are ready to call the Metamap SDK in order to do our first verification. There are two options to call the Metamap SDK