Text

HOW TO IMPORT ITC into your already existing Android Studio Gradle project

If you want to integrate ITC (ATK 1.3) into your Android Studio Gradle project, you will have to follow the steps below:
1. Add libs and jar file in the 'libs' folder of your application:
- sdk/libs (libMyScript2D.so, ..., libMyScriptEngine.so, ..., libMyScriptText.so)
- styluscore/libs (libStylusCore.so)
- itc/libs (libAtkItc.so)
- AtkItc jar file
- com.myscript.atk.styluscore.jar file
2. Edit build.gradle file of your application and add this block in the android section:
sourceSets.main {jniLibs.srcDir 'libs'}
3 You can then use PageInterpreter and other ITC classes by adding:

import com.myscript.atk.itc.*;
import com.myscript.atk.itc.Error;


4 You also need to copy resources into the 'assets' folder of your application:
- copy sample/itc/assets folder in your application (for instance: ITC1.3Gradleappsrcmainassets)
- copy the SimpleResourcesHelper.java from itc/sample/util
5 Add MyCertificate.java file in your project
- make sure the package name is the same than the bundle Identifier set on atk.myscript.com
- replace the byte array with the content of the certificate 'com.bundleIdentifier.name' downloaded from atk.myscript.com

6. example of snippet to add in 'MainActivity'.java:

PageInterpreter pageInterpreter = new PageInterpreter(getApplicationContext());

pageInterpreter.setPageInterpreterListener(new IPageInterpreterListener() {
@Override
public void configureBegin(PageInterpreter pageInterpreter) {
Log.d("ITCAPP", "configureBegin");
}

@Override
public void configureEnd(PageInterpreter pageInterpreter, boolean success, String lang) {
Log.d("ITCAPP", "configureEnd");
if (!success) {
Log.e("ITCAPP", "Configuration Error: '" + pageInterpreter.getRecognitionErrorString() + "'");
}
}
});

DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
List<String> resources = new ArrayList<>();
resources.add("en_US/en_US-ak-cur.lite.res");
resources.add("en_US/en_US-lk-text.lite.res");
SimpleResourceHelper helper = new SimpleResourceHelper(this);
final List<String> paths = helper.getResourcePaths(resources);
List<String> lex = new ArrayList<>();
com.myscript.atk.itc.Error error = pageInterpreter.configure("en_US", paths, lex, MyCertificate.getBytes(), displayMetrics.densityDpi);
if(error.getError() != Error.ErrorCode.NoError) {
Log.e("ITCAPP", "Configuration Error: '" + error.getErrorMessage() + "'");
}


NB: please make sure to have all permission required in the AndroidManifest of your application:

uses-permission android:name="android.permission.INTERNET" 
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"

Please let us know if you have any question.
Best regards

1 Comment

A new ATK package is now available:
https://developer.myscript.com/get-started
You will be able to open the Single Line Text widget project directly in Android Studio with gradle build.
A new version of MathWidget, GeometryWidget and SingleChar widget is also available in this ATK2 package.

Please let us know if you have any other question.
Best regards

Login or Signup to post a comment
  • Support
  • Forums
  • Text
  • HOW TO IMPORT ITC into your already existing Android Studio Gradle project