Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modifying contents of Android .aar file / Converting to and from .zip format

So I have a .aar file which has a file I need to remove from inside it.

I am running on mac and changed the extention from .aar to .zip and unzipped the zip file. I then removed the file from the folder, recompressed it back into a .zip and then tried changing the extension from .zip back to .aar.

The problem is that the now modified .aar is not recognized as a .aar file. It is still being registered as a .zip and I can no longer use it in my project.

So my question is two fold:

1) How can one easily modify the contents of a .aar file and 2) How do you properly convert to/from .aar and .zip?

like image 405
user1782677 Avatar asked Aug 09 '16 21:08

user1782677


People also ask

How do I extract a .AAR file?

In android studio, open the Project Files view. Find the . aar file and double click, choose "arhcive" from the 'open with' list that pops up. This will open a window in android studio with all the files, including the classes, manifest, etc.

What is a .AAR file?

An AAR file contains a software library used for developing Android apps. It is structurally similar to an . APK file (Android Package), but it allows a developer to store a reusable component that can be used across multiple different apps.


1 Answers

Supposing you have mylib.aar in your current directory, try the following:

$ unzip myLib.aar -d tempFolder # or other extracting tool # Change whatever you need $ jar cvf myNewLib.aar -C tempFolder/ . 
like image 147
Salem Avatar answered Sep 19 '22 04:09

Salem