Error in YourFont Extension

Hi, today I was using YourFont extension in my projects which was made my ken. But when I use the extension, I get error that asset not found.

Screenshot

I don't know why its happening.

Did you tried exporting apk

Because there is similar bug in niotron. Custom fonts not works in companion but works in apk

1 Like

Yes, I will try it, when my lappy is charged :grinning:

When using the Companion the app's assets are moved to an external folder so you'll need Read External Storage permissions:
android.permission.READ_EXTERNAL_STORAGE

2 Likes

I am asking the permission, but the error still exits :sweat_smile:, sorry for the late reply.

Font asset not found /storage/emulated/0/AppInventor/assets/GoogleSans-Regular.ttf

Also I checked my phone's internal storage, i din't see any folder called AppInventor!
Can @anyone check it please?

While testing (using Companion) on devices with API < 29 the assets are stored in:

/storage/emulated/0/AppInventor/assets/

On devices with API ≥ 29 the assets are stored in (the ASD):

/storage/emulated/0/Android/data/<pachageName>/files/assets/

With the compiled app (APK) the assets are stored in the Internal Storage:

/data/data/<packageName>/

grafik

See also here:

1 Like

When using Companion it depends on the Android version in which location the assets are stored ... → see my answer above.

Since when?
No, READ_EXTERNAL_STORAGE is always granted using Companion.

I have tested the APK (YourFont.apk) from @Ken's extension test aia on Android 9, 10, 11.
No issues.

Which device & Android version do you use?

I use android 9 & 10.

Actaully I have no problem with the compiled APK, but with companion, I cant compile my large app again and again... :sweat_smile:

Ok, but I don't think this has anything to do with Ken's extension.

1 Like

I am having the same issue. Writing the APK works, but running in AI companion does not. I believe the issue is as @Anke points out the location of asset storage. If I run the YourFont demo app in AI companion on an old Android 8 phone the app runs as expected. If I run on an Android 10 phone I get the same error as the OP with none of the new fonts displayed. If you look at line 74 of the .java file the developer included in his original post File file = new File("/storage/emulated/0/AppInventor/assets/" + fontFileName);
He has hardcoded the location to the old < android 10 location. I looked on appybuilder for the original version to try and modify it to work for newer phones but could not find it. I also tried using the .java file to make my own on appybuilder version with /storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/assets/ substituted, but there were numerous build errors that are beyond my very basic copy/paste voodoo coding to comprehend.

Yes, I modified the extension, try this:myFonts.aia (246.2 KB)

Check it on your Android 10 or 11 device and on Android < 10 devices (Companion & APK).

`

1 Like

Fine.

:question:

I think he is talking about he can't compile apk to do testing again and again.

He cannot compile the app (aia), but he said:

1 Like

Thank you @Anke. MyFont behaves correctly in AI companion on both devices. Well done using your avatar pic as extension icon :+1:. Is the .aix available somewhere for MyFont so I can import it into other projects?

Yes, but I'm not sure if I can publish it because the idea for YourFont came from @Ken.

In the end there would be two extensions:

  • one for Kodular (the current version from @Ken) and
  • one for AI2.