Skip to content

Conversation

jarlisson2
Copy link
Contributor

With this implementation it is possible to add an .aar type library in extension. Just use the existing annotation "@UsesLibraries (libraries ="library.aar ") and add the library to the dependencies, just like the .jar files.

@AppInventorWorkerBee
Copy link
Collaborator

Can one of the admins verify this patch?

@ewpatton
Copy link
Member

ewpatton commented Jul 3, 2020

@AppInventorWorkerBee ok to test

@shreyashsaitwal
Copy link
Contributor

shreyashsaitwal commented Aug 24, 2020

Can this change get staged for nb185?

cc @ewpatton

@ewpatton
Copy link
Member

@shreyashsaitwal This won't go into nb185. We could consider it for nb186. The goal with nb185 is first and foremost to fix issues that cropped up in nb184.

@tomer2526
Copy link

We need to implement this so that we can solve the problem of building this extension: https://community.kodular.io/t/suggestion-for-building-an-extension/77477/15
Please add this in the next update🙏

@armandojr1159
Copy link

Como usar a extensão para checar CNPJ?
Vi que foi incluído o trecho de tratamento para CNPJ entretanto não consigo a verificação. Está apenas para CPF mesmo?.
Muito bom o seu trabalho. Parabéns

@joseluu
Copy link

joseluu commented Oct 23, 2020

Will the resources contained in the aar end up in the application ? (as expected)

@ewpatton ewpatton modified the milestones: September Release, nb187 Dec 1, 2020
@joseluu
Copy link

joseluu commented Jan 20, 2021

Note: I am using this patch on my compilation server, it works, I hope you will integrate it soon.

@m-anshuman2166
Copy link

@ewpatton Any news regarding aar support ?

@bigraymasoom
Copy link

Any update on this project?

Change-Id: I6422e47b0dcdb7b3536658fe276b189aea4c01a3
@ewpatton
Copy link
Member

ewpatton commented Feb 7, 2025

I've updated this on top of the latest master.

@jewelshkjony
Copy link
Contributor

Would it be possible to merge this change with nb201?

@bigraymasoom
Copy link

Yes, please

Copy link
Contributor

@jewelshkjony jewelshkjony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested it locally after merging with mit's latest master branch, and it works perfectly with AARs in extensions. (ref)

Copy link
Contributor

@jewelshkjony jewelshkjony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed a bug in ExternalComponentGenerator.java at #362. It is only including the last declared AAR. It should include all declared AARs. This is how I solved (ref).

These changes need to be addressed.

@bigraymasoom
Copy link

I guess it's not included in latest release.

@ewpatton ewpatton added this to the nb202 milestone Aug 7, 2025
@jewelshkjony
Copy link
Contributor

I have identified a problem with the inability to merge JNI/native (.so) libraries.

@ewpatton
Copy link
Member

ewpatton commented Aug 10, 2025 via email

@jewelshkjony
Copy link
Contributor

It'd be awesome if this PR also get merged.

@bigraymasoom
Copy link

If this feature is merged then libraries related issues will be resolved very much in MIT App inventor ecosystem and will see many modern extensions related to UI and other modern android related features. One thing that i noticed is that assets in libraries( talking about nested assets) in the libraries are not included in the build apk. Also, I suggest that there should be two ways how assets are merged into the apk. First like traditional way, assets are placed under extension package folder in assets folder of apk. Second should be the root folder with nested folders lead to file as many libraries refer to the root folder path like /assets/org/test/file.js instead of /assets/file.js or in case of extension /assets/extension.package.name/file.js.

@bigraymasoom
Copy link

bigraymasoom commented Aug 11, 2025

There is also another way (again it's just a suggestion) is to place libraries related assets as they are like single file or folder within folder lead to file in the root of assets folder instead of placing them under their extension package name folder. OR we can give users ability in the designer section of App inventor frontend to create the files structure as they like(but again it will not be the scope of this PR but it will solve assets related issues as users can create their own file structures like simple file under assets folder like /assets/simplefile.js or in nested structured file path like /assets/folder_name/simplefile.js).

@jewelshkjony
Copy link
Contributor

It would be great if this feature also handle merging assets and jni libraries.
Otherwise, the goal of attaching AAR will remain incomplete!

Copy link
Member

@ewpatton ewpatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assets in extensions can always be included using @UsesAssets, which has always been true, and there is a separate PR to worry about native libs so I do not think it is worth holding up the release on those grounds.

String library = librariesNeeded.getString(j);
copyFile(buildServerClassDirPath + File.separator + library,
extensionTempDirPath + File.separator + library);
copyFile(buildServerClassDirPath + File.separator + library, extensionTempDirPath + File.separator + library);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend restoring the original formatting here for this call as nothing has changed semantically.

copyFile(buildServerClassDirPath + File.separator + library,
extensionTempDirPath + File.separator + library);
copyFile(buildServerClassDirPath + File.separator + library, extensionTempDirPath + File.separator + library);
if(library.endsWith(".aar")){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix whitespace after if and before {

i.remove();
if (!processedLibs.contains(libname)) {
if (!processedLibs.contains(lib)) {
if (simpleCompTypes.contains(type) || type == "ANDROID") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewrite the latter half of this conditional as "ANDROID".equals(type).

@ewpatton ewpatton merged commit 8d9c796 into mit-cml:master Aug 14, 2025
2 checks passed
@bigraymasoom
Copy link

Assets in extensions can always be included using @UsesAssets

Thanks for merging this Sir. Really appreciated. But assets from aars will not be included in the apk. Build process will just ignore them at appinventor/buildserver/src/com/google/appinventor/buildserver/tasks/android/AttachCompAssets.java. It's looking for extension assets and during unzipping aar libraries assets will be ignored from asset list.

@jewelshkjony
Copy link
Contributor

Assets in extensions can always be included using @UsesAssets, which has always been true, and there is a separate PR to worry about native libs so I do not think it is worth holding up the release on those grounds.

The @UsesAssets annotation includes the assets of an extension under the extension's package name. However, assets included in the AAR file should be placed in the application's root assets directory. This pull request resolves this issue by merging the assets from the AAR into the application's root directory, and your review of the pull request would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add full support for aar files