Interactive Ink

invalid certificate after linking complete module of myscript to another app

.healthcare.SplashActivity}: java.lang.IllegalArgumentException: invalid certificate

        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)

        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)

        at android.app.ActivityThread.-wrap11(Unknown Source:0)

        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)

        at android.os.Handler.dispatchMessage(Handler.java:106)

        at android.os.Looper.loop(Looper.java:164)

        at android.app.ActivityThread.main(ActivityThread.java:6494)

        at java.lang.reflect.Method.invoke(Native Method)

        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)

        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

     Caused by: java.lang.IllegalArgumentException: invalid certificate

        at com.myscript.iink.NativeFunctions.createEngine(Native Method)

        at com.myscript.iink.Engine.<init>(Engine.java:19)

        at com.myscript.iink.Engine.create(Engine.java:38)

        at com.welkinfort.healthcare.IInkApplication.getEngine(IInkApplication.java:18)

        at com.welkinfort.healthcare.SplashActivity.onCreate(SplashActivity.java:38)

        at android.app.Activity.performCreate(Activity.java:7009)

        at android.app.Activity.performCreate(Activity.java:7000)

        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)

        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)

        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 

        at android.app.ActivityThread.-wrap11(Unknown Source:0) 

        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 

        at android.os.Handler.dispatchMessage(Handler.java:106) 

        at android.os.Looper.loop(Looper.java:164) 

        at android.app.ActivityThread.main(ActivityThread.java:6494) 

        at java.lang.reflect.Method.invoke(Native Method) 

        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 

  1.         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 


Dear Karan,


Thank you for your question.


in your console, I see the following error message: Mismatch between certificate and application: com\.myscript\..+ != com....


This usually occurs when the bundleIdentifier is not properly set in your project: https://developer-support.myscript.com/support/discussions/topics/16000007816


Can you please check this and let us know if it doesn't work?


Best regards,


Olivier

Still not able to remove the error . followed your steps as you mentioned above.

one suggestion for user point of view, Please provide an practical example that may help many and get to know how to integrate myscript in there respective applications

Thank you


Dear Karan,


Indeed, I can see in your console the identifier has not been updated, you are still getting the same error: "Mismatch between certificate and application: com\.myscript\..+ != com.wel"


Basically, all you need to do is update the package variable in your AndroidManifest.xml, and you should no longer get the error. More explanation is available in the following link: https://developer.myscript.com/support/account/on-device-license-management/#certificate


Best regards,


Olivier



 java.lang.NullPointerException: Attempt to invoke virtual method 'void com.myscript.iink.uireferenceimplementation.InputController.setInputMode(int)' on a null object reference.

Now this is occurring after even after declaring 

editorView.setInputMode(InputController.INPUT_MODE_FORCE_PEN);

Dear Karan,


To better understand your issue, can you please send me your code sample ?


Regards,


Maël

 In this Fragment class, I am trying to set input Mode to the editor view but it gives null on object reference as for your to get things easier, I had already declared (editorview) in the fragment and layout file  properly  but still getting error while setting the input mode to the editorview.

package com.welkinfort.healthcare.Fragment;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;

import com.myscript.iink.Configuration;
import com.myscript.iink.ContentPackage;
import com.myscript.iink.ContentPart;
import com.myscript.iink.ConversionState;
import com.myscript.iink.Editor;
import com.myscript.iink.Engine;
import com.myscript.iink.IEditorListener;
import com.welkinfort.healthcare.ErrorActivity;
import com.welkinfort.healthcare.Handwritting.EditorView;
import com.welkinfort.healthcare.Handwritting.InputController;
import com.welkinfort.healthcare.IInkApplication;
import com.welkinfort.healthcare.R;
import com.welkinfort.healthcare.fullscreendialog.FullScreenDialogContent;
import com.welkinfort.healthcare.fullscreendialog.FullScreenDialogController;

import java.io.File;
import java.io.IOException;

public class ContentFragment extends Fragment implements FullScreenDialogContent, View.OnClickListener {
    public static final String EXTRA_NAME = "EXTRA_NAME";
    public static final String RESULT_FULL_NAME = "RESULT_FULL_NAME";
    private FullScreenDialogController dialogController;
    AlertDialog alertDialog;
    private Engine engine;
    private ContentPackage contentPackage;
    private ContentPart contentPart;
    private EditorView editorView;

    private static final String TAG = "FragmentActivity";

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        final View view = inflater.inflate(R.layout.writting_pop_up_activity,
                container, false);
        ErrorActivity.installHandler(getActivity());
        editorView = view.findViewById(R.id.editor_view);
        editorView.setInputMode(InputController.INPUT_MODE_FORCE_PEN);
        view.findViewById(R.id.button_input_mode_forcePen).setEnabled(InputController.INPUT_MODE_FORCE_PEN != InputController.INPUT_MODE_FORCE_PEN);
        engine = IInkApplication.getEngine();

        // configure recognition
        Configuration conf = engine.getConfiguration();
        String confDir = "zip://" + getActivity().getPackageCodePath() + "!/assets/conf";
        conf.setStringArray("configuration-manager.search-path", new String[]{confDir});
        String tempDir = getActivity().getFilesDir().getPath() + File.separator + "tmp";
        conf.setString("content-package.temp-folder", tempDir);


        editorView.setEngine(engine);

        final Editor editor = editorView.getEditor();

        editor.addListener(new IEditorListener() {
            @Override
            public void partChanging(Editor editor, ContentPart oldPart, ContentPart newPart) {
                // no-op
            }

            @Override
            public void partChanged(Editor editor) {
                getActivity().invalidateOptionsMenu();
                invalidateIconButtons(view);
            }

            @Override
            public void contentChanged(Editor editor, String[] blockIds) {
                getActivity().invalidateOptionsMenu();
                invalidateIconButtons(view);
            }

            @Override
            public void onError(Editor editor, String blockId, String message) {
                Log.e(TAG, "Failed to edit block \"" + blockId + "\"" + message);
            }
        });

        setInputMode(InputController.INPUT_MODE_FORCE_PEN); // If using an active pen, put INPUT_MODE_AUTO here

        String packageName = "File1.iink";
        File file = new File(getActivity().getFilesDir(), packageName);
        try {
            contentPackage = engine.createPackage(file);
            contentPart = contentPackage.createPart("Text Document"); // Choose type of content (possible values are: "Text Document", "Text", "Diagram", "Math", and "Drawing")
        } catch (IOException e) {
            Log.e(TAG, "Failed to open package \"" + packageName + "\"", e);
        } catch (IllegalArgumentException e) {
            Log.e(TAG, "Failed to open package \"" + packageName + "\"", e);
        }

        getActivity().setTitle("Type: " + contentPart.getType());

        // wait for view size initialization before setting part
        editorView.post(new Runnable() {
            @Override
            public void run() {
                editorView.getRenderer().setViewOffset(0, 0);
                editorView.getRenderer().setViewScale(1);
                editorView.setVisibility(View.VISIBLE);
                editor.setPart(contentPart);
            }
        });

        view.findViewById(R.id.button_input_mode_forcePen).setOnClickListener(this);
        view.findViewById(R.id.button_input_mode_forceTouch).setOnClickListener(this);
        view.findViewById(R.id.button_input_mode_auto).setOnClickListener(this);
        view.findViewById(R.id.button_undo).setOnClickListener(this);
        view.findViewById(R.id.button_redo).setOnClickListener(this);
        view.findViewById(R.id.button_clear).setOnClickListener(this);

        invalidateIconButtons(view);
        return view;
    }


    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        inflater.inflate(R.menu.writting_menu, menu);

        MenuItem convertMenuItem = menu.findItem(R.id.menu_convert);
        convertMenuItem.setEnabled(true);
        super.onCreateOptionsMenu(menu, inflater);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_convert: {
                Editor editor = editorView.getEditor();
                ConversionState[] supportedStates = editor.getSupportedTargetConversionStates(null);
                if (supportedStates.length > 0)
                    editor.convert(null, supportedStates[0]);
                return true;
            }
            default: {
                return super.onOptionsItemSelected(item);
            }
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button_input_mode_forcePen:
                setInputMode(InputController.INPUT_MODE_FORCE_PEN);
                break;
            case R.id.button_input_mode_forceTouch:
                setInputMode(InputController.INPUT_MODE_FORCE_TOUCH);
                break;
            case R.id.button_input_mode_auto:
                setInputMode(InputController.INPUT_MODE_AUTO);
                break;
            case R.id.button_undo:
                editorView.getEditor().undo();
                break;
            case R.id.button_redo:
                editorView.getEditor().redo();
                break;
            case R.id.button_clear:
                editorView.getEditor().clear();
                break;
            default:
                Log.e(TAG, "Failed to handle click event");
                break;
        }
    }

    private void setInputMode(int inputMode) {
        editorView.setInputMode(inputMode);
        getView().findViewById(R.id.button_input_mode_forcePen).setEnabled(inputMode != InputController.INPUT_MODE_FORCE_PEN);
        getView().findViewById(R.id.button_input_mode_forceTouch).setEnabled(inputMode != InputController.INPUT_MODE_FORCE_TOUCH);
        getView().findViewById(R.id.button_input_mode_auto).setEnabled(inputMode != InputController.INPUT_MODE_AUTO);
    }

    private void invalidateIconButtons(final View view) {
        Editor editor = editorView.getEditor();
        final boolean canUndo = editor.canUndo();
        final boolean canRedo = editor.canRedo();
        getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ImageButton imageButtonUndo = (ImageButton) view.findViewById(R.id.button_undo);
                imageButtonUndo.setEnabled(canUndo);
                ImageButton imageButtonRedo = (ImageButton) view.findViewById(R.id.button_redo);
                imageButtonRedo.setEnabled(canRedo);
                ImageButton imageButtonClear = (ImageButton) view.findViewById(R.id.button_clear);
                imageButtonClear.setEnabled(contentPart != null);
            }
        });
    }

    @Override
    public void onDialogCreated(FullScreenDialogController dialogController) {
        this.dialogController = dialogController;
    }

    @Override
    public boolean onConfirmClick(FullScreenDialogController dialogController) {
        Bundle result = new Bundle();
        result.putString(RESULT_FULL_NAME, getArguments().getString(EXTRA_NAME) + " " + "Abc");
        dialogController.confirm(result);
        return true;
    }

    @Override
    public boolean onDiscardClick(final FullScreenDialogController dialogController) {
        alertDialog = new AlertDialog.Builder(getContext())
                .setTitle(R.string.discard_confirmation_title)
                .setMessage(R.string.discard_confirmation_message)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialogController.discard();
                        editorView.setOnTouchListener(null);
                        editorView.close();

                        if (contentPart != null) {
                            contentPart.close();
                            contentPart = null;
                        }
                        if (contentPackage != null) {
                            contentPackage.close();
                            contentPackage = null;
                        }


                        // IInkApplication has the ownership, do not close here
                        engine = null;
                    }
                })
                .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // Nothing to do
                    }
                }).show();

        return true;
    }

    @Override
    public boolean onExtraActionClick(MenuItem actionItem, FullScreenDialogController dialogController) {
        return false;
    }
}

 

Dear Karan,


EditorView must be associated with an iink Engine, otherwise it cannot do anything.
What is missing is likely a call to

editorView.setEngine(engine);


Please refer to the sample implementation provided, this is the very first operation performed after 

editorView = findViewById(R.id.editor_view);


You should do the same.


Regards,


Maël

Login or Signup to post a comment