String IndexOutOfBounds Exception while using extensions in companion app

Install the test Companion on your phone.

I don't have any real device with android...

Bkuestacks is emulating on Samsung Galaxy S22 Ultra

Logcat :

11-29 17:27:51.320  3969  3969 I Form    : calling Initialize method for Object edu.mit.appinventor.aicompanion3.Screen1@e614b56
11-29 17:27:51.323  3969  3969 D ReplForm: returnRetvals: {"status":"OK","values":[{"status":"OK","type":"return","value":"","blockid":"-1"}]}
11-29 17:27:51.325  3969  3969 W System.err: java.lang.RuntimeException: invoke: no method named `OpenDatabase' in class java.lang.Boolean
11-29 17:27:51.325  3969  3969 W System.err:    at gnu.kawa.reflect.Invoke.lookupMethods(Invoke.java:284)
11-29 17:27:51.325  3969  3969 W System.err:    at gnu.kawa.reflect.Invoke.applyN(Invoke.java:185)
11-29 17:27:51.325  3969  3969 W System.err:    at gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:139)
11-29 17:27:51.325  3969  3969 W System.err:    at gnu.kawa.functions.Apply.applyN(Apply.java:70)
11-29 17:27:51.325  3969  3969 W System.err:    at gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)
11-29 17:27:51.325  3969  3969 W System.err:    at com.google.youngandroid.runtime.callComponentMethod(runtime15361636460425333856.scm:1113)
11-29 17:27:51.326  3969  3969 W System.err:    at java.lang.reflect.Method.invoke(Native Method)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.expr.PrimProcedure.apply(PrimProcedure.java:285)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.mapping.CallContext.getFromContext(CallContext.java:263)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.expr.Expression.eval(Expression.java:26)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.expr.BeginExp.apply(BeginExp.java:114)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.expr.Closure.apply(LambdaExp.java:2154)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.mapping.CallContext.getFromContext(CallContext.java:263)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.expr.Expression.eval(Expression.java:26)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.expr.BeginExp.apply(BeginExp.java:114)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.expr.LetExp.apply(LetExp.java:70)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.expr.Closure.apply(LambdaExp.java:2154)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.mapping.CallContext.runUntilValue(CallContext.java:298)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.mapping.MethodProc.applyN(MethodProc.java:113)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:139)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.kawa.functions.Apply.applyN(Apply.java:70)
11-29 17:27:51.326  3969  3969 W System.err:    at gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)
11-29 17:27:51.326  3969  3969 W System.err:    at edu.mit.appinventor.aicompanion3.Screen1.dispatchEvent(Screen1.yail:10132)
11-29 17:27:51.326  3969  3969 W System.err:    at com.google.appinventor.components.runtime.EventDispatcher.delegateDispatchEvent(EventDispatcher.java:237)
11-29 17:27:51.326  3969  3969 W System.err:    at com.google.appinventor.components.runtime.EventDispatcher.dispatchFallibleEvent(EventDispatcher.java:211)
11-29 17:27:51.326  3969  3969 W System.err:    at com.google.appinventor.components.runtime.EventDispatcher.dispatchEvent(EventDispatcher.java:187)
11-29 17:27:51.326  3969  3969 W System.err:    at com.google.appinventor.components.runtime.Form$3.run(Form.java:900)
11-29 17:27:51.326  3969  3969 W System.err:    at android.os.Handler.handleCallback(Handler.java:873)
11-29 17:27:51.326  3969  3969 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:99)
11-29 17:27:51.326  3969  3969 W System.err:    at android.os.Looper.loop(Looper.java:193)
11-29 17:27:51.326  3969  3969 W System.err:    at android.app.ActivityThread.main(ActivityThread.java:6816)
11-29 17:27:51.326  3969  3969 W System.err:    at java.lang.reflect.Method.invoke(Native Method)
11-29 17:27:51.326  3969  3969 W System.err:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:518)
11-29 17:27:51.326  3969  3969 W System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
11-29 17:27:51.326  3969  3969 D ReplForm: returnRetvals: {"status":"OK","values":[{"status":"OK","type":"error","value":"invoke: no method named `OpenDatabase' in class java.lang.Boolean"}]}
11-29 17:27:51.329  3969  3969 D Form    : Sizing(Responsive)
11-29 17:27:51.330  3969  3969 D Form    : formWidth = 600 formHeight = 1066

Does it have a Google Pixel variant? If so, try that.

Same error

Did you also try Legacy checkbox ?

My guess is something going on inside the emulator. I have no issues on Genymotion with a Pixel, Android 12.

That said, the ultimate aim is for things to work everywhere. Holiday weekend at MIT, so this may have to wait until next week.

1 Like

Logcat from bluestacks emulator, based on android 11:

PS C:\Windows\system32> adb logcat -s ReplForm
--------- beginning of kernel
--------- beginning of main
--------- beginning of system
11-29 19:53:01.167  5182  5182 D ReplForm: onCreate
11-29 19:53:02.131  5182  5182 D ReplForm: onCreateFinish() Called in Repl
11-29 19:53:02.133  5182  5182 D ReplForm: Intent = Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=edu.mit.appinventor.aicompanion3/.Screen1 bnds=[632,242][715,338] }
11-29 19:53:02.134  5182  5182 D ReplForm: Did not receive any data
11-29 19:53:03.519  5182  5182 D ReplForm: HandleReturnValues() Called, replResult = null
11-29 19:53:28.223  5182  5182 I ReplForm: started AppInvHTTPD
11-29 19:53:38.802  5182  5182 D ReplForm: componentFolder = /storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/assets/external_comps
11-29 19:53:38.804  5182  5182 D ReplForm: loadComponent.getAbsolutePath() = /storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/assets/external_comps/pl.listviewplus/classes.jar
11-29 19:53:38.804  5182  5182 D ReplForm: loadComponent.exists() = false !loadedExternalDexs(loadComponent.getName()) = false loadComponent.getName() = classes.jar
11-29 19:53:38.824  5182  5182 D ReplForm: returnRetvals: {"status":"OK","values":[{"status":"OK","type":"error","value":"Unable to load extensions.java.lang.StringIndexOutOfBoundsException: String index out of range: -1"}]}
11-29 19:53:38.827  5182  5182 D ReplForm: returnRetvals: {"status":"OK","values":[{"status":"OK","type":"return","value":"","blockid":"-1"}]}

I have just tested the test Companion on a Samsung S8 with Android 9.

When I run companion for the first time and connect to the project I get an error:

An empty folder is created:

storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/AppInventor/assets/external_comps/pl.listviewplus

It does not contain a jar file or other files.

After another attempt to connect to the same project, I get an error in the appinventor window:

Unable to load extensions.java.lang.StringIndexOutOfBoundsException: String index out of range: -1
*Note:* You will not see another error reported for 5 seconds.

Logcat from Samsung S8 android 9:

First run:

28916 edu.mit.appinventor.aicompanion3     D  onCreate
28916 edu.mit.appinventor.aicompanion3     D  onCreateFinish() Called in Repl
28916 edu.mit.appinventor.aicompanion3     D  Intent = Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=edu.mit.appinventor.aicompanion3/.Screen1 (has extras) }
28916 edu.mit.appinventor.aicompanion3     D  Did not receive any data
28916 edu.mit.appinventor.aicompanion3     D  extras: Bundle[{profile=0}]
28916 edu.mit.appinventor.aicompanion3     D  Extra Key: profile
28916 edu.mit.appinventor.aicompanion3     D  HandleReturnValues() Called, replResult = null
28916 edu.mit.appinventor.aicompanion3     I  started AppInvHTTPD
28916 edu.mit.appinventor.aicompanion3     D  componentFolder = /storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/AppInventor/assets/external_comps
28916 edu.mit.appinventor.aicompanion3     D  returnRetvals: {"status":"OK","values":[{"status":"OK","type":"error","value":"Unable to load extensions.java.lang.StringIndexOutOfBoundsException: String index out of range: -1"}]}
28916 edu.mit.appinventor.aicompanion3     D  returnRetvals: {"status":"OK","values":[{"status":"OK","type":"return","value":"","blockid":"-1"}]}

Second run:

28365 pid-28365                            D  onCreate
28365 pid-28365                            D  onCreateFinish() Called in Repl
28365 pid-28365                            D  Intent = Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=edu.mit.appinventor.aicompanion3/.Screen1 (has extras) }
28365 pid-28365                            D  Did not receive any data
28365 pid-28365                            D  extras: Bundle[{profile=0}]
28365 pid-28365                            D  Extra Key: profile
28365 pid-28365                            D  HandleReturnValues() Called, replResult = null
28365 edu.mit.appinventor.aicompanion3     I  started AppInvHTTPD
28365 edu.mit.appinventor.aicompanion3     D  componentFolder = /storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/AppInventor/assets/external_comps
28365 edu.mit.appinventor.aicompanion3     D  loadComponent.getAbsolutePath() = /storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/AppInventor/assets/external_comps/pl.listviewplus/classes.jar
28365 edu.mit.appinventor.aicompanion3     D  loadComponent.exists() = false !loadedExternalDexs(loadComponent.getName()) = false loadComponent.getName() = classes.jar
28365 edu.mit.appinventor.aicompanion3     D  returnRetvals: {"status":"OK","values":[{"status":"OK","type":"error","value":"Unable to load extensions.java.lang.StringIndexOutOfBoundsException: String index out of range: -1"}]}
28365 edu.mit.appinventor.aicompanion3     D  returnRetvals: {"status":"OK","values":[{"status":"OK","type":"return","value":"","blockid":"-1"}]}

I think the above fix works on android 14+, but not older ones.

in Bluestacks / with a Samsung device?

The fixed companion works for me on Android 12 using Genymotion, and on Android 13 real device...both of which are Google Pixels.

1 Like

Yes, it is set to Samsung S22Ultra and the real device with Android 9 is also Samsung. So it turns out that the problem is still with Samsung. We need more tests with Samsung. I will check by setting another phone in Bluestacks.

Yes, after changing the phone in bluestacks to xiaomi 11, the project loads correctly. So the problem is still Samsung, at least with android < 14. Someone would have to check on Samsung with android 14+.

Hi,
isn't there a mistake in the naming of the .jar files?
I tried the AI2 Offline Companion application ver. 2.72 and everything works fine there. I noticed that Class saves the files under a different name than the latest MIT AI2 Companion v 2.73


I use Xiaomi Mi A3 Android 11

Same with Galaxy Note8 (Android 9). Now it doesn't even work with USB connection.

just tried with genymotion
Doesn't work
same error

What device did you use as your emulator ?

On Chromebook companion (android 13) not working, used to work but now it is broken, I cant install updated version since Chromebook restrictions, can you try adding it as a beta in Google play store?

Please release this on to the Google Play store - school Chromebooks are blocking individual app downloads for security reasons and allowlists specific Google play store apps, can you provide this fix to the Google Play Store version? Thanks,
Foxyonfire

For this to be published to google play it has to be tested and work as intended. There is still a problem on Samsung devices so the fix needs further work so it can't be published.

1 Like

The problem is not only with Samsung devices, I get it also e.g. with a Xiaomi Mi 9 (Android 10) and a Huawei P20 lite (Android 9).

1 Like

yeah but the andriod 13 glitch is the one I want to get fixed plz, cant they be released seperatrrley? like the 2.73t2u version and the 2.73d1u version?

It's strange, because I tested the test companion on an emulator with Android 11, and when I select a device other than Samsung there it works, but when I select Samsung, then it doesn't work.
I'll do more testing on different emulators because we need to sort this out.

1 Like

You can sideload a version of the companion app, unless this is prevented by your schools setup

1 Like

Yes, it Is prevented, it is supposedly for "security reasons" but I think they just dont want people getting around their browser restrictions, I will talk about it to the schools tech department though. Will this update get on to the official companion eventually?