Help With Chromecast Extension

Continuando la discusión desde Error from Companion: java.lang.NoClassDefFoundError:

Hello everyone!

I decided to try to create the Chromecast extension by myself, I have managed to solve the problem related to Classes and jar files, so I need to create the methods

One of the methods that the library includes is ChromeCasts.get(), this returns a List type, but I have to convert it to YailList, what would be the most correct way to do that?


error: incompatible types: List<ChromeCast> cannot be converted to YailList
[javac] return ChromeCasts.get();
[javac]                        ^
[javac] 1 error

To convert a List to a YailList you could do something like the following:

YailList chromeCasts = YailList.makeList(ChromeCasts.get());
3 Likes

Indeed it compiled without problems, but it returns an empty List

What I see also is that in ChromeCasts.java (from the Library) it says “return new ArrayList”

Will it be related? :thinking:

#Off-Topic

@Peter your son is a genius, don’t do this to him :joy:

You can return a straight List type from a method, you don’t need to return YailList. The runtime will coerce the List into a YailList. However, we generally don’t try to expose non-YAIL types in the blocks since one can’t do anything with them. Instead we provide methods to access information about the internal objects (cf. BluetoothClient). You may want to consider a similar pattern.

2 Likes

Ok, @Krishjha07 has helped me solve some problems, however it still returns an empty list


I found this Issue in the Repository of the used library, but I think it affects only computers, since I have seen other Android projects using this library

1 Like

@Alexander Are you able to build a very basic app in Android Studio using the library? At least that would allow us to ensure that you have code that works, in which case it’s just a matter of figuring out how to integrate it into an extension.

4 Likes

I have never used Android Studio before, but I guess I can try it


I will install it

2 Likes

After several days of research and help received, I think we reached the cause of the error :thinking:

When implementing a .OnError block it shows us that the StartingDeviceDiscovery process stops due to android.os.NetworkOnMainThreadException :confused:

I did a little more research and came to the conclusion that this process should be done asynchronously :slight_smile:


I will report the results when I do more tests :bulb:


Thanks Evan and Bart for the kind attention! :hugs:

2 Likes

I don't think it will work.
AsyncTask is the best option.

1 Like

Yes, I saw your post on Kodular Community about this recommendation @vknow360 :smiley:


I’ll do a little more research since I’m not very knowledgeable about it :sweat_smile:

2 Likes

It is quite easy to implement once you have learnt about its usage.
This can be helpful:

2 Likes

Can you give me a working example?

...without any meaningful reason. I have no idea that why some developers hate it so much.

1 Like

@Alexander I would recommend that you make use of the AsynchUtil class:

You can see uses of it in other components that do network activity, such as the Web component.

2 Likes

Apparently at least in Kodular Creator this might sometimes not work and closed the app

Although apparently it works fine now



I think I will make the repository public so that those interested can help :hugs:

2 Likes

I have used the Extensions template and GitHub Actions

Unfortunately, I can’t really speak to any stability issues in Kodular w.r.t. to the use of AsynchUtil there. In App Inventor, we use AsynchUtil in many different components in App Inventor, so if there were an actual problem with it I would expect that we’d be seeing a lot of reports (we had almost 650k users in the last 30 days). For example, it’s used as part of the WebRTC negotiation when you connect your companion to the browser.

According to an analysis with IntelliJ, AsynchUtil is used in the following components:

  • BluetoothServer
  • File
  • Map
  • FeatureCollection
  • MediaUtil; for loading images from the web and called from a plethora of components, including:
    • ButtonBase and its associated subclasses (Button and all Picker elements)
    • Canvas
    • Form (Screen)
    • Image
    • ImageSprite
  • Navigation
  • TinyWebDB
  • Twitter
  • Web
  • WebRTCMgr (companion connection management)
  • YandexTranslate

:crying_cat_face:

1 Like

Hi @ewpatton
First of all thanks for sharing so much knowledge.
Honestly I haven’t used most of the AI2 components.
I mostly use AI2 for testing my extensions.So I am aware of those uses of AsychUtil.
But recently I have experienced a lot of issues by using AsynchUtill such as unexpected closing of application.
That’s is why I wrote above post on Kodular Community.
I also thought to report bug here but somehow I was able overcome the issues using AsyncTask so didn’t reported bug here.And I am feeling very sorry for that.
But I don’t know how it is working now :thinking:

Do you experience issues in App Inventor, Kodular, or both? Did you capture any stack traces via adb logcat for the crashes?

I experienced issues on both builders.First on Kodular because users reported bugs there then I tested on App Inventor and found that it is not working on both.

Sorry I use android 4.4 so either I have not so much options for debugging or I don't have proper knowledge about debugging.
Can I get logcat now?