String IndexOutOfBounds Exception while using extensions in companion app

This is the output I get from adb logcat *:E when connecting with code

11-22 09:26:56.625 14085 14085 E AssetFetcher: Error in form.loadComponents
11-22 09:26:56.625 14085 14085 E AssetFetcher: java.lang.StringIndexOutOfBoundsException: start 1, end 0, length 0
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at java.lang.AbstractStringBuilder.checkRangeSIOOBE(AbstractStringBuilder.java:1729)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:1022)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at java.lang.StringBuilder.substring(StringBuilder.java:87)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:973)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at java.lang.StringBuilder.substring(StringBuilder.java:87)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at com.google.appinventor.components.runtime.ReplForm.loadComponents(ReplForm.java:480)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at com.google.appinventor.components.runtime.util.AssetFetcher.loadExtensions(AssetFetcher.java:137)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at java.lang.reflect.Method.invoke(Native Method)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at gnu.expr.PrimProcedure.apply(PrimProcedure.java:285)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at gnu.mapping.CallContext.runUntilValue(CallContext.java:298)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at gnu.mapping.MethodProc.applyN(MethodProc.java:113)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at gnu.mapping.ProcedureN.apply0(ProcedureN.java:24)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at kawa.lang.Promise.force(Promise.java:27)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at kawa.lang.Promise.force(Promise.java:37)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at kawa.lib.misc.force(misc.scm:99)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at com.google.youngandroid.runtime$frame9.lambda20(runtime4706405383590784482.scm:3569)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at com.google.youngandroid.runtime$frame9.apply0(runtime4706405383590784482.scm:3566)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at gnu.expr.ModuleMethod.apply0(ModuleMethod.java:186)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at gnu.mapping.RunnableClosure.run(RunnableClosure.java:78)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at android.os.Handler.handleCallback(Handler.java:942)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at android.os.Handler.dispatchMessage(Handler.java:99)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at android.os.Looper.loopOnce(Looper.java:201)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at android.os.Looper.loop(Looper.java:288)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at android.app.ActivityThread.main(ActivityThread.java:7918)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at java.lang.reflect.Method.invoke(Native Method)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
11-22 09:26:56.625 14085 14085 E AssetFetcher: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

1 Like

and more from a adb logcat

logcat.txt (33.0 KB)

there were hundreds of these as well

11-22 09:22:22.782  4205  5356 E Finsky  : [63] mxv.apply(797): AU2: RequiredVehicleState is missing.
11-22 09:22:22.783  4205  5356 E Finsky  : [63] mxv.apply(857): AU2: RequiredInteractivityState is missing.
11-22 09:22:22.784  4205  5356 E Finsky  : [63] mxv.apply(987): AU2: RequiredBatteryLevel is missing.

3 posts were split to a new topic: My app fails Play Store pre-launch tests

I have the same problem (getting the out-of-bounds message when trying to run latest version of companion). Running Android 13 on Samsung S20. Everything was working fine yesterday morning with older version of companion (2.70?). Accidently deleted it off my phone. Reloaded companion from Google Play. Gotten the error ever since. Any way to get access to older versions of companion to try?

I don't get this error, but I can't connect to the companion because the extension jar file isn't being sent, and neither are resources like images. Oddly enough, everything works fine on my locally compiled server.

Here is a shared Sync.com archive of recent Companions:

The problem seems to be in Companion itself. When I use Companion compiled locally, this error does not occur.

Once my locally compiled Companion has downloaded the resources and jar files to ASD, then connecting to Companion installed from GooglePlay works fine. So the problem is in downloading resources from the server to ASD.

Maybe the new Companion after the ListView hot fix will fix the situation.

1 Like

We don't apply any patches in production that would affect the extension loading path. I'm going to run some tests and see if I can reproduce it.

1 Like

On 2.73u:

AssetFetcher            usap64                              usap64                               E  Error in form.loadComponents (Ask Gemini)
                                                                                                                                        java.lang.StringIndexOutOfBoundsException: start 1, end 0, length 0
                                                                                                                                        	at java.lang.AbstractStringBuilder.checkRangeSIOOBE(AbstractStringBuilder.java:1729)
                                                                                                                                        	at java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:1022)
                                                                                                                                        	at java.lang.StringBuilder.substring(StringBuilder.java:87)
                                                                                                                                        	at java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:973)
                                                                                                                                        	at java.lang.StringBuilder.substring(StringBuilder.java:87)
                                                                                                                                        	at com.google.appinventor.components.runtime.ReplForm.loadComponents(ReplForm.java:480)
                                                                                                                                        	at com.google.appinventor.components.runtime.util.AssetFetcher.loadExtensions(AssetFetcher.java:137)
                                                                                                                                        	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                                                        	at gnu.expr.PrimProcedure.apply(PrimProcedure.java:285)
                                                                                                                                        	at gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
                                                                                                                                        	at gnu.mapping.CallContext.runUntilValue(CallContext.java:298)
                                                                                                                                        	at gnu.mapping.MethodProc.applyN(MethodProc.java:113)
                                                                                                                                        	at gnu.mapping.ProcedureN.apply0(ProcedureN.java:24)
                                                                                                                                        	at kawa.lang.Promise.force(Promise.java:27)
                                                                                                                                        	at kawa.lang.Promise.force(Promise.java:37)
                                                                                                                                        	at kawa.lib.misc.force(misc.scm:99)
                                                                                                                                        	at com.google.youngandroid.runtime$frame9.lambda20(runtime4706405383590784482.scm:3569)
                                                                                                                                        	at com.google.youngandroid.runtime$frame9.apply0(runtime4706405383590784482.scm:3566)
                                                                                                                                        	at gnu.expr.ModuleMethod.apply0(ModuleMethod.java:186)
                                                                                                                                        	at gnu.mapping.RunnableClosure.run(RunnableClosure.java:78)
                                                                                                                                        	at android.os.Handler.handleCallback(Handler.java:958)
                                                                                                                                        	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                                                        	at android.os.Looper.loopOnce(Looper.java:222)
                                                                                                                                        	at android.os.Looper.loop(Looper.java:314)
                                                                                                                                        	at android.app.ActivityThread.main(ActivityThread.java:8658)
                                                                                                                                        	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                                                        	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:565)
                                                                                                                                        	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)

I think this error may simply be due to lack of resources in the ASD Companion.

The first attempt to connect after installing Companion ended with an error. Another attempt and the connection was problem-free. Something is not stable.

In my case there were 3 error symptoms:

  • error: java.lang.StringIndexOutOfBoundsException
  • error: Unable to load file...../classes.jar
  • and a problem that after updating the extension with new methods, these methods were not available in companion, i.e. the classes.jar file did not update in asd but the connection to companion was successful.
1 Like

@Mike_B , @Patryk_F

What happens if you try a project without extensions ? (as previously suggested)

What happens if you try a project with no extensions but also with some media assets ?

Without extensions it work in all my tablets and android versions

1 Like

Thank you, we are getting somewhere.

@Taifun

Should we create a new topic, e.g. Companion Extension Issues: nb199 and 2.73u and move all the topics there ?

3 Likes

i have same issue, i use companion v 2.72 first, when error occured maybe because im not updating the companion app, after i update the error still there, i tried to build apk its working, then i tried on empty app without any extension just label and textbox its connected fine using companion app, maybe the problem is in extension

my device is redmi note 11 pro 5g with android 13

Here is something to try.

When you experience this problem, try uninstalling the Companion and then installing it fresh.

I suspect the problem is caused by an interrupted download of the extension jar file, leaving behind a zero length file, which could cause this out of bounds exception.

I did, still got the error, or progress bar just stopped at trying to load the classes.jar file.

What is causing it, I have a pretty solid internet connection, the error arises at different times of the day, and this error is happening to people all over the world?

Also see here:

It broke suddenly, I think since Tuesday. Previously there was no such problem on a global scale. Sometimes there was an interruption but very sporadic, now it works sporadically.

It would also be helpful to get a logcat when this failure happens, in particular the entries before the stack trace. I'm looking for a message that starts with: "Loading component dex".

Also try legacy connection. Non legacy connections use WebRTC. With WebRTC, the browser chooses which "ports" to use. I suspect that some ports are being blocked by various network elements. So success may depend on which ports the browser (randomly) chooses. Unfortunately, this choice is beyond our ability to influence. This is just a theory on my part, however.

I waste also a lot of time developping extension and trying with the Emulator 2.65 or my Samsung S9. In conclusion these two modes are buggy. My workaround is to build the APK and try it with my phone without errors!
Last bug was to say me that "all but first of list" doesn't exist!!!