Troubleshooting Android KMSample1 and KMSample2

Hi,
I am also working on the tutorial to build a system keyboard for Android.
Unfortunately, I get “fatal error for <code_language>. Loading default keyboard”.
Both apps buid and install correctly but the keyboard fails to load.
Anything I might have missed?
A file I forgot to edit?
Any help welcome.

Cheers
Ibrahima

I am also working on the tutorial to build a system keyboard for Android

To confirm, are you going through the KMSample2 guide for creating a system keyboard?

Can you provide additional details about your configuration?

  • Are you using the latest stable Keyman 13.0 project?
  • Does your keyboard file contain a version number in the name?

In this example, tamil99m.js has a keyboard version 1.1, so it is renamed to tamil99m-1.1.js .

  • Can you paste what you have in /KMSample2/app/src/main/java/com/keyman/kmsample2/SystemKeyboard.java?
    The original would be
    // Add a custom keyboard
    HashMap<String, String> kbInfo = new HashMap<String, String>();
    kbInfo.put(KMManager.KMKey_PackageID, "basic_kbdtam99");
    kbInfo.put(KMManager.KMKey_KeyboardID, "basic_kbdtam99");
    kbInfo.put(KMManager.KMKey_LanguageID, "ta");
    kbInfo.put(KMManager.KMKey_KeyboardName, "Tamil 99 Basic");
    kbInfo.put(KMManager.KMKey_LanguageName, "Tamil");
    kbInfo.put(KMManager.KMKey_KeyboardVersion, "1.0");
    //kbInfo.put(KMManager.KMKey_Font, "aava1.ttf");
    kbInfo.put(KMManager.KMKey_Font, KMManager.KMDefault_KeyboardFont); // Use the default font
    KMManager.addKeyboard(this, kbInfo);

Thank you very much @darcy for your reply.
I am going through the KMSample2 indeed. And I am using Keyman Developer 13. Actually I tried to adapt it to my language Fulah by replacing all those parameters from Tamil example.

This is what I have in /KMSample2/app/src/main/java/com/keyman/kmsample2/SystemKeyboard.java

 // Add a custom keyboard
 HashMap<String, String> kbInfo = new HashMap<String, String>();
    kbInfo.put(KMManager.KMKey_PackageID, "cloud");
    kbInfo.put(KMManager.KMKey_KeyboardID, "pulaarful");
    kbInfo.put(KMManager.KMKey_LanguageID, "ff");
    kbInfo.put(KMManager.KMKey_KeyboardName, "Tappirde Pulaar-Fulfulde 2020");
    kbInfo.put(KMManager.KMKey_LanguageName, "Fulah");
    kbInfo.put(KMManager.KMKey_KeyboardVersion, "1.1");
    //kbInfo.put(KMManager.KMKey_Font, "AdelleSansEXT-Regular.otf");
    kbInfo.put(KMManager.KMKey_Font, KMManager.KMDefault_KeyboardFont); // Use the default font
    KMManager.addKeyboard(this, kbInfo);

I changed a few things and file names to adapt to my language but I am sure I did something wrong. Because when I run the app in its original Tamil configuration, it works.
Actually I think the tutorial is missing a few steps explaining everything we need to change. I realized there is a folder names example.ta.wordlist, fot example that I renamed to adapt to Fulah language. Was that a requirement?
Cheers
Ibrahima

I get a new error:

Can’t set cloud:::(keyboard) for XX language

Ah, I just noticed the guide has old screenshots that use a deprecated “languages” folder.

From your setup, it sounds like your keyboard should be in
/KMSample2/app/src/main/assets/cloud/pulaarful-1.1.js

KMSample1 (the in-app keyboard example) has the models/example.ta.wordlist/ folder. We can troubleshoot getting your lexical model to work after we figure out your system keyboard.

It actually worked after a lot of tweaking and headache :slight_smile:! Actually, I have used the Tamil example without moving any file, just replaced files and renamed to match code changes.
Now it works but I have the wrong keyboard.js file (an old one I already updated).

A few questions

  1. I was wondering how to generate a new keyboard.js file to use in the …/assets/cloud folder.:
  2. My lexical model language code is different from the keyboard language code. Is that a problem? If so I have to change the lexical model to match the keyboard language ID, how?

EDIT: Lexical model work only with sample1, not in system-wide keyboard. What could cause that?

Thank you very much for your much appreciated help!
Ibrahima

  1. I was wondering how to generate a new keyboard.js file to use in the …/assets/cloud folder:

Follow step 4 onward from the in-app guide to generate a new keyboard.js file and copy to assets/cloud/.
Note, the lines of code to change in step 5 are
MainActivity.java for KMSample1
SystemKeyboard.java for KMSample2


  1. My lexical model language code is different from the keyboard language code. Is that a problem? If so I have to change the lexical model to match the keyboard language ID, how?

Yes, that is a problem. You’ll need to change the lexical model language ID to match what the keyboard language ID has.
That’s done in Keyman Developer with your lexical model project open

  1. In your project view, click the “Packaging” tab. This should open the GUI for your .kps file
  2. In the package view, click the “Lexical Models” tab. You’ll see a panel to add a BCP 47 language tag

Lexical model work only with sample1, not in system-wide keyboard. What would cause that?

KMSample1 (MainActivity.java) has lines to add a dictionary

    // Add a dictionary
    HashMap<String, String>lexicalModelInfo = new HashMap<String, String>();
    lexicalModelInfo.put(KMManager.KMKey_PackageID, "example.ta.wordlist");
    lexicalModelInfo.put(KMManager.KMKey_LanguageID, "ta");
    lexicalModelInfo.put(KMManager.KMKey_LexicalModelID, "example.ta.wordlist");
    lexicalModelInfo.put(KMManager.KMKey_LexicalModelVersion, "1.0");
    KMManager.addLexicalModel(context, lexicalModelInfo);
    KMManager.registerAssociatedLexicalModel("ta");

You’ll need to paste those into KMSample2 (SystemKeyboard.java) and edit accordingly

Respectfully, due to the inactiveness of the conversation, this topic is now closed for any further discussion.
Please feel free to create a new topic if there is any question or the issue persists.