Help finding an external library (not adding)

Hello, I think I understand how to add external libaries reading this article.

I am trying to add androidx libraries, I believe it is what I need to create a background service using WorkManager. Anyway my issue is I cannot seem to find .jar/aar library files for that package! Everything I read online tells me that I must use maven/build.gradle.

Maybe this library is incompatible? Cant we target API29? I seem to be able to find other libraries .jar/.aar files easily?

Thanks!

1 Like

Hello Horacio

Your Forum Topic needs to be in the Open Source Development category:
https://community.appinventor.mit.edu/c/open-source-development/10

the androidx libraries are already there, no need to add them... you only have to import them in your source code...
Taifun

Hi @Horacio_Spinelli
You can find available AndroidX libs here:
https://mvnrepository.com/artifact/androidx

Yes thats the one I want but I cant figure out how to get the jar files :frowning: specifically https://mvnrepository.com/artifact/androidx.work

And @Taifun, I can import all those packages but not androidx.work.* :frowning:

I just noticed there is a little field to download the .aar files!

image

Im a big noob so I need to ask, can just place this file instead of the .jar file?

Hello please give me some guidance as to what the heck I just did.

I downloaded the .aar file (since I read it includes a .jar file) and I used a decompressor to just extract all the .jar files (in this case classes.jar, inspector.jar, and init.jar). I then imported those 3 files as java libraries and it appears it is all working (I can import androidx.work.WorkManager). Is this a fine approach?

(The three files I took)

image

I havnt tested running code yet because I dont have any, but I feel like it wont work, I think i need that res folder, and not inspector.jar or init.jar :confused:

I feel like if its on maven I should be using

image

image

but I get

image

Which is why Im trying to do it manually, cant figure out how to find maven "coordinates" or whatnot for said package.

EDIT: I got a message back from a developer of my IDE and was told that I should use maven, or my workaround will be tedious and that my problem is I need to set up my project specifically as a maven project so that I can add/change where maven searches for repositories. In my case add https://maven.google.com. I will try that tonight and report back, hopefully the info isnt just helpful to my IDE.

EDIT2: I think I may be complicating things to much since now I need to set up maven with ant... but i still cant figure out how to get the package i want imported into my project :frowning: unless my workaround is fine.. going to hope that works

1 - Download the aar file
2 - Extract the classes.jar from that
3 - Paste in a subdirectory in lib folder
4 - Add the entry to component/build.xml
5 - In extension use @UsesLibraries annotation

2 Likes

Wish I didn't waste any time trying on my own, that is so simple, thanks :slight_smile:

Totally solves my issue!

Yes, that will work but only when classes don't use resources of aar.
And if it does then you will have to do same for aar also i.e.

As far I know the aar support for extension still not merged into master branch. So there is no way of using aar in extensions.

Yes, but what is this then:
https://docs.google.com/document/d/1xk9dMfczvjbbwD-wMsr-ffqkTlE3ga0ocCE1KOb2wvw/pub#h.3kn0fmfydnq1

The document title says "How to Add a Component"

Extensions are also components i.e. external components.
But the documents does not say anything about extension template so it is understable that aar is only effective when you compile extension using the source.

I don't want to get into this unnecessary argument.

Extension != Component even if its externalComponent

Because

  1. Extensions does not support aar, as of now, both in extension template and the ai2 source (@jarlissonlira2 's patch still not merged)
  2. Extensions cant have a mock in the viewer, as of now (@pavi2410 's patch still not merged)

If you search a bit, You will get to know this statement is not true at all

And if it does then you will have to do same for aar also i.e.
3 - Paste in a subdirectory in lib folder
4 - Add the entry to component/build.xml
5 - In extension use @UsesLibraries annotation

I thought I had to do this regardless

Excuse my noobness, but can you elaborate? How would I check? And if it does would I copy the /res folder from the .aar file also (to a subdirectory in /lib in my project)?

Currently I'm just importing the classes.jar file from the .aar as I do not understand.

Thanks

Maybe I should just apply @jarlissonlira2's patch and use the .aar?

Even if you build the extension using @Jarlissonlira2 's patch, aar will not work, the distributions where you want to use the extension should use the patch as well. Extraction of jar from aar file is the only way as of now