Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I package .so files into my .aar archive?

I was wondering if it's possible to package my native .so files into my .aar file? If so, where would the .so files go and are there any references that I can read in regards to this?

like image 363
Kamilski81 Avatar asked Apr 22 '15 16:04

Kamilski81


People also ask

How do I add an AAR file to libs?

Add your AAR or JAR as a dependencyNavigate to File > Project Structure > Dependencies. In the Declared Dependencies tab, click and select Jar Dependency in the dropdown. In the Add Jar/Aar Dependency dialog, first enter the path to your . aar or .

How do I unpack an .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 .AAR file is used for?

In addition to JAR files, Android uses a binary distribution format called Android Archive(AAR). The . aar bundle is the binary distribution of an Android Library Project. An AAR is similar to a JAR file, but it can contain resources as well as compiled byte-code.


2 Answers

jni/<platform>/libexample.so

doesn't work.

It should be src/main/jniLibs/<platform>/libexample.so

http://www.codepool.biz/build-so-aar-android-studio.html

like image 135
Wilson Chen Avatar answered Sep 19 '22 23:09

Wilson Chen


If you put it manually, then it should be placed underneath

jni/<platform>/libexample.so

where platform is a target CPU platform like "armeabi", "x86" etc. Typically you will have so-files for multiple platforms there. If you build from source code using Gradle you could simply put your native source code to

src/main/jni/

and build plugin will do the rest. As the resulting so-files will be built automatically and placed where they belong to.

Regarding the references, I've seen this been mentioned somewhere on the site dedicated to Android build plugin for Gradle. Since then I wasn't able to find this page again. But you can check out plugin's source code for more details.

like image 44
sergej shafarenka Avatar answered Sep 20 '22 23:09

sergej shafarenka