Help getting started with extension development

As per i understood u need to import jar to rush.

So as the solution

add your .jar to deps folder and after that in rush.yml you will get this line at last

# Dependencies declared here should be present in the "deps" directory.

# deps:

#   - my_awesome_library.jar

you have to remove the #

# Dependencies declared here should be present in the "deps" directory.

 deps:

   - my_awesome_library.jar

it is necessary to add - before the jar.

Okay, that much is understood and has been done. The question is, is it necessary to import this into the project and how?

Yes if u want to use the external imports you have to do these things

1 Like

Sorry, is that really quite old fashioned?
:thinking:

5 Likes

If it is , then I love Old-Fashioned :sweat_smile: :grin: :grin:

4 Likes

I still use it and love it, its good too :sweat_smile::blush:

2 Likes

Put the downloaded JAR file in the deeps directory.
Edit the rush.yml file adding your dependencies

deps:
  - beanshell.jar

Make sure there are no extra lines below.
Now the dependency will be compiled along with the extension.


Just to import to the project (or let IDE index the JAR), you have to right-click on it, then select “Add As library” if you are using IntelliJ IDEA.

Then you will be able to normally import packages (for the code editor).

2 Likes

Of course not, just a figure of speech.

I’m using VSCode, as there is no such facility here I ask.
The import of the library is like this?
import com.laboratoriodosfundos.supabase

This is no longer required and IntelliJ IDEA (or any other JetBrains IDE) should be able to automatically index dependencies for every extension created using Rush 1.1.1 or higher.

4 Likes

So after editing the rush.yml file you don’t need to do anything else to import the library?

Nope, I didn’t mean that. Just like every other Java/Kotlin program, importing necessary external classes is required for extensions as well.

3 Likes

And how this is done,
by giving the file name, package name?
Can you give me an example?

This is basic … Did you really have tried writing simple programs in java ??

To import java package into a class , we need to use java import keyword which is used to access package and its classes into the java program. Use import to access built-in and user-defined packages into your java source file so that your class can refer to a class that is in another package by directly using its name.

@laboratoriodosfundos

Besides not having had much contact with Java, I haven’t programmed in Java for years.
But I program in several languages and it is just a matter of practicing.
I am not just waiting for an answer from you, I am analyzing several extension codes, mainly the AppInventor source code, and what I have found is this:
@UsesLibraries(libraries = “json.jar”)
But this causes an error when compiling Rush.
Also, testing how an extension works is extremely annoying, so I’m turning to you, otherwise I wouldn’t be bothering you.

That annotation doesn’t exists in Rush, and that’s the reason behind errors. Instead, you need to declare any external dependency of your extension in rush.yml as stated previously by others.

As you mentioned you’re new to Java, I’d like to recommend you to use either IntelliJ IDEA or Android Studio as an IDE. Although VS Code is great for almost every other language and framework out there, it doesn’t quite play well with Java (and so with Rush).

Using either of the above mentioned IDEs will also help solve your confusion around import statements as they are able to auto-import required classes as you write your code.

4 Likes

And did you practiced??

Several programmers including me also used to ask different questions without realizing how actually java works… I’ve made my first extension and had published it when i even don’t know different small things of java … I didn’t know about Arrays , neither Methods , Interface or anythings… After realizing things , I then patiencly and slowly learned and still learning things…
importing any classes is the basic of java …in every programs, required imports are necessary …

Of course, so the developers had replied you with such answers:

And for imports ,

And you are still asking ,

So why i asked you

and said you how imports are done …


Thanks a lot, I’ll download IntelliJ IDEA, VSCode is showing many errors in the code, which is also disturbing a lot. I had already understood that it was some difficulty to analyze the project and Rush doesn’t identify some annotations.

1 Like

@laboratoriodosfundos I hope you are well,

Here we mean like if I use a library named rx.jar, then I need to import its classes, A jar is a bundle of classes

So, as I said, for an example, I used a jar named rx.jar, so I will need to add these in imports

import rx.android.plugins.*;

import rx.android.schedulers.*;

import rx.android.*;

import rx.functions.Action1;

import rx.android.schedulers.AndroidSchedulers;

import rx.functions.Action1;
1 Like

Hi, I used Aixc and Eclipse to build extension. You can read this with help of google translation.
https://www.kevinkun.cn/aixc.html

copy the jar file into lib folder, in Eclipse add it to build path, then the IDE will add the necessary import automatically.

don’t forget to add the @UsesLibaries annotation

2 Likes