Assets in Extension Development

Hello everybody here
I am having one issue in Extension Development that I wanted to discuss

Actually I was building an extension in which some Stylish text is present using some code I was returning it in the form of Arrays but...
When I have compiled the extension using Rush it says me

unmappable character for encoding

Then I thought that I should take values from assets in the from of text and return as Arrays
But I am stuck there
I was trying this method

But unfortunately I wasn't able to
Anybody who can help me then please....
Thank you

1 Like

Hi there,
Here's a way to load files from assets.
InputStream is = context.getAssets().open("filename.txt");
Then you can use it to read the file

String text;
while((character = != -1) {
    text = text + character;

There seem to be two different issues in this post. I'm not familiar with how rush works, but any errors it provides are during the compilation stage. More context about the error message "unmappable character for encoding" would be helpful there. Certainly for any text files I would highly encourage the use of UTF-8 although sometimes Windows is configured with a different encoding (macOS and Linux typically default to UTF-8).

Separately regarding the loading of extensions in the code, it is important to use form.openAssetForExtension because this appropriately handles whether your extension is loaded in the companion app or loaded in a compiled app. I guess if your extension cannot be used in the companion (i.e., it needs a permission not declared by the permission), then it might be okay, but otherwise you risk the situation where people can only test by compiling their apps, which isn't a great experience.


Yes @ewpatton I also have to use this method because

It won't be a great idea

@SimpleFunction(description = "ReadFile")
public String LoadData(String inFile) {
String tContents = "";

try {
    InputStream stream =contex.getAssets().open(inFile);

    int size = stream.available();
    byte[] buffer = new byte[size];;
    tContents = new String(buffer);
} catch (IOException e) {
    // Handle exceptions here

return tContents;


The extension is compiled without errors, but it does not work in the companion, nor with the compiled apk


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.