String IndexOutOfBounds Exception while using extensions in companion app

To complicate matters further, here is a contribution from me. :wink: Tested on a Pixel 7 Pro (Android 14):

  1. I established the connection via USB and some of my extensions initially did not generate an error message. (The APK works as it should, of course.)

  2. I then also tested the app with Niotron via Companion (WiFi connection).

  3. When I add another extension (TaifunFile), I get this error message:

The extensions all appear in the right place:


When connecting to Companion I get the same error message as (almost) everyone else:

I also attempted connecting via USB, just gave me a white screen on device, and runtime error about not being able to set properties for the extension (so it got somewhere but obviously did not load the classes.jar file...)

companionTest_USB.aia (10.8 KB)

Not true. Some days ago, all worked perfectly.

Hi, same issue,
Companion version is 2.73
Android 12

You got the no such class error, which sometimes appeared also in the past... therefore on the extensions directory webpage I have this chapter for that kind of error

How to avoid runtime errors with the companion app

  1. After importing an extension, please restart the companion app.
  2. If you like to use an extension on a different screen, in Screen1 additionally drag the extension into the working area.

While starting the companion app, all necessary assets and also the imported extensions of your project will be copied to your device. So in case the no such class error shows up, the extension code to run the extension is not available on your device. Without that code the companion app is not able to execute methods from the extension.

In case restarting the companion app does not work for you after trying several times, then as it looks like the only way for you to test you app will be after building it using the apk file.

Taifun

I get the same error for almost every other extension. I always delete the Companion folder and reload the browser before testing an extension. That doesn't change anything.

As everyone knows, it also worked with Companion before. If we can basically only test with the compiled app, we don't need Companion anymore.


And as you can see from my example, it works without any problems with Niotron.

Yesterday I had the same problem, I assumed it was the extension and I updated it and that solved my problem, I was able to create the apk.

Is it probably due to some compiler update that causes the extensions to no longer grab some Java 8 methods? :thinking:

I have the same problem using KIO4_base64 and ClickZ, when i try to lunch the app on companion it gives me this error:
"Unable to load extensions.java.lang.StringIndexOutOfBoundsException:
String index out of range: -1"
companion version: 2.73 (from app store)
Phone: Samsung A30s
Android version: 11

So I was able to reproduce the problem. That means it's only a matter of time until I have it fixed. I'll probably post a binary of a fixed companion within the next 24 hours.

6 Likes

Thank you jis for your work, in Italy is 23.05pm😂. See you in ~14h

The fix is now up on ai2-test. You can download the updated companion, version 2.73t2u directly here.

companion

3 Likes

Going to test it today and give to you some feedback...

Strange because I had this problem for a few days on Android 14. In addition, I read in PR that on Android14 the jar file has the same name as the extension. In my case, it was still classes.jar in the error.

On Android 11 with Companion Version: 2.73t2u

  • Unable to load extensions.java.lang.StringIndexOutOfBoundsException: String index out of range: -1

Android 11 with Companion Version: 2.73u

  • everything works fine.

On Android 14 with Companion Version: 2.73t2u
In the console:

  • invoke: no method named `SetBackgroundColor' in class joejsanz.joedevglassmorphism.JoeDevGlassMorphism

On the device:

  • Unable to load
    file:https://ai2.appinventor.mit.edo/ode/download/file/6507989327478784/assets/external_comps/joejsanz.joedevglassmorphism/classes.jar

The apk of my project is installed and works perfectly, but in companion it has that error.

1 Like

Did you use ai2test server as well ?

Ran tests on three devices, using both the ai2test server and ai2 server, with companion 2.73tu.

For me this has fixed the "String IndexOutOfBounds" error on Android 12 (genymotion) and Android 13 (Pixel 4a)

Well done Jeff !!

What remains is a continuing issue with Android 14/15 in loading a project with an updated extension which is returning the error of being unable to load the classes.jar. This is with tests on Android 15 Pixel 8a. This failed to load to the two projects I tested, which loaded just fine with Android 12 & 13.

Yes, both servers.

Yes, it also works on my Pixel 4XL (Android 13), but it doesn't work on Android 14 (Pixel 7 Pro). The same error as before.

Working fine on android 11 (Samsung A30s) Emulator v2.73t2u
The only "problem" when you launch it on the companion shows to update the version of the companion skippable pressing "not now"