70

How do I extract code from aar file.[Accidentally my main project is on another system can't access only have aar file on my mail]

I need to extract the JNI code from aar file. I tried to change the extension to .jar but its extract .class only, Do anybody know how to extract that aar thing.

Sophia
  • 1,046
  • 1
  • 12
  • 15

5 Answers5

149

Example: libraryproject.aar

  1. Change the file extension to ".jar" example: libraryproject.jar

  2. Extract the jar file into a folder.

  3. The folder will have AndroidManifest, resources and library files used in the android library project.

  4. The folder will also have a classes.jar file, which will have all the classes in the library.

  5. To open classes.jar, use jd-gui tool.

  6. In the jd-gui tool, File ->Open, File->browse and select classes.jar file.

medavox
  • 175
  • 2
  • 11
Srinivasan
  • 4,481
  • 3
  • 28
  • 36
27

In android studio, open the Project Files view.

enter image description here

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.

Sharone Lev
  • 791
  • 7
  • 15
  • 2
    I would expect that to happen, and I think it actually happened in the past, now with AS 3.4.1 it says there's no application associated to that .aar file and prompts me to chose one to open it... I hate these things... – Fran Marzoa Jun 21 '19 at 10:23
  • 5
    @FranMarzoa select "Archive" from the list. – Martin Marconcini Jun 30 '19 at 11:22
  • In my case, I need to install this plugins first: https://plugins.jetbrains.com/plugin/index?xmlId=io.github.lizhangqu.intellij.plugin.android.bundle – mochadwi Aug 01 '19 at 09:23
  • 1
    I had to just double click on the AAR from the project view, it then would allow me to browse the source inside. It would also allow me to compare the AAR against another AAR file. – Pellet Jan 05 '21 at 03:45
  • 1
    .aar is a .jar which is a .zip so rename the file to .zip and violá – Jacksonkr Mar 14 '22 at 19:52
12

Only two steps:

  1. Rename the library file extension to ".jar", like: lib.jar

  2. Extract the file in a folder with Winrar, Winzip, etc.

avisper
  • 878
  • 12
  • 11
8

.aar file has zip format, but it contains compiled code of the module only. If your .aar includes JNI, it will be in form of a shared library. You can use it as a prebuilt shared library as long as you can keep it unchanged. You cannot decompile it as easily as the .class files.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
4

Just open preferences, search for plugins and search Android Bundle Support plugin in the search bar. You need to install this plugin to open .aar and .jar files. https://plugins.jetbrains.com/plugin/10310-android-bundle-support/

viper
  • 1,836
  • 4
  • 25
  • 41
  • 1
    how can i open .aar file after install Android Bundle Support ?, please can you explain that's steps ?. – Basant Dec 26 '20 at 12:46