Got this error "java.lang.RuntimeException: no such class" when import extension

I'm sorry, I misread your post.

If you haven't, you should exit the companion and reconnect again for starters. The extension is considered like an asset file and sent to the companion when you are connecting, and maybe, the extension is not sent to your device.

If this still persists, then you may have to build the app in order to test.

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.

Taken from App Inventor Extensions | Pura Vida Apps.

If that still is a problem, clear the assets of your companion and try.

Android or iOS?
Error message? Post a screenshot of it.

1 Like

I am using Android ver 9 on my phone, connected via USB
The extension I am currently trying to use is ColinTreeListView but that same happens no matter which I try (FirebaseAuth, FirebaseStorage, TaifunTextBox and more always fails).
I will try that clear assets shortly.

This is actually funny (not).
I imported that deleteAssetsCompanion.aia, certainly does not load into companion, so I built it and installed and list files show blank array delete files seems to do nothing.
I restart the browser and companion upon restart the deleteAssetsCompanion was the last project so it autoloads and wham case in point error.

Does this simple test app work for you (with TaifunTextbox extension):
TaifunTextbox.aia (18.8 KB)

If not, post a screenshot again and try to connect via "AI Companion" (WiFi).

I got a different error now.
Screenshot from 2022-12-25 04-44-58

BTW: I saw another flash by before that

Build the APK and try ...

Did you connect via "AI Companion" (or via USB again)?

Via USB, I have no WIFI to try.
For what its worth I've been filtering logcat and I see a bunch of _values POST but I don't see _extensions.
12-25 04:59:03.449 20200 20254 D AppInvHTTPD: POST '/_values'

So did you try testing with the APK?

Btw, I have no issues with USB connection.

1 Like

Yes I did test with APK, that works fine. Using the APK is how i've using AI2 because the companion has never worked with extensions for me but its become a pain to do so here I am trying to get it working.
When I examine the logs and grok the code it almost seems like the scheme code is getting evaluated before the extension get there.
Still groking

I wonder if me running Linux has anything to do with it. Mark my words I will track this issue down since my last little app took about 100 build/download/install apk. I'm done with that cycle.
I'll report my finding on here, thanks a lot for your help so far.

Very curios error via logcat...

12-25 06:25:32.542 22764 22764 D ReplForm: onCreate
12-25 06:25:32.545   688  2137 I StorageManagerService: Cmd send mkdirs /dev/null/Android/data/edu.mit.appinventor.aicompanion3/files/
12-25 06:25:32.545   283   283 E vold    : Failed to find mounted volume for /dev/null/Android/data/edu.mit.appinventor.aicompanion3/files/
12-25 06:25:32.547 22764 22764 W ContextImpl: Failed to ensure /dev/null/Android/data/edu.mit.appinventor.aicompanion3/files: java.lang.IllegalStateException: Failed to prepare /dev/null/Android/data/edu.mit.appinventor.aicompanion3/files/: android.os.ServiceSpecificException:  (code -22)

Are you guys certain that extension can be loaded via USB connection?
I ask this because looking at the code for all this the only mechanism I can see for actually getting extensions over to the Companion is via the AssetFetcher.loadExtensions which builds a list and calls ReplForm.loadComponents which then fetches the file with the url provided from replmgr.js, This does not get called at all when you are in usb/emulator mode so how could it be working.
I have gotten it working for myself but my fix would not work unless you are running locally.

My fix is as follows:

File: appinventor-sources/appinventor/blocklyeditor/src/replmgr.js
Added the line to line 1170
top.ReplState.hasfetchassets = true;
This is what tells it to process extensions.

File: appinventor-sources/appinventor/misc/emulator-support/aiStarter.py
Added the line to line 125
subprocess.check_output('"%s" -s %s reverse tcp:8888 tcp:8888' % (ADB, device), shell=True)

This just sets up a forward from my phone to my local machine running AI2, it just works then.
A more permanent fix would be to just implement the rendezvous stack into aiStarter and it could in turn fetch the files and pass it along.

Cheers!

If it doesn't work under Linux for you, you could certainly run Windows under Linux. (However, I've never done it.) As I said, I've been using AI2Starter for almost 10 years now on various versions of Windows and on dozens of computers/notebooks without any problems.

A post was merged into an existing topic: Java Error Error from Companion: java.lang.RuntimeException: invalid syntax in eval form: :8:1: caught exception in inliner for # - java.lang.RuntimeException: no such class: