How to import and use .aar file while creating extensions

Actually is there any proper way and guide on how to use .aar file while creating extensions ?
I have searched and found some related topics to it but there is no proper solution to it.
I want help on how to import .aar file
And how to import it on Java file and use it ?
Is there any proper way to go ?
I know that there are some limitations but is there any proper guide to it ?
If there is no proper guide let’s create this topic as guide . Let’s write or comment the solutions properly who knows ?

2 Likes

I know I can use .aar file by extracting the .jar file from it but it will not help always ,
Because library may have dependency to values.xml and other files so ?
How we can resolve ?

1 Like

You’re already using the classes.jar which is extracted from the .aar. Now you may convert the R.txt to R.java. It might be helpful for you.

See here how to easily convert R txt to R.java:

An advance & paid solution also available:

1 Like

Thank you for replying now my question is
There might be dependencies with res/drawable/values.xml and many more .
I have seen that library is dependent to draw able .xml files and other values.xml many times , how to resolve these type of dependencies ?

1 Like

.aar file is not directly supported. You need to modify or create your own classes to work without xml files. R.java file will help you to avoid compile time error, sometimes its required & helps on runtime too.

For resolving R.txt the idea is
Extract .aar file
Get and Extract .jar file of extracted .aar file
Convert R.txt to R.java file
Add R.java to extracted jar file and compile it to jar file again ?
Could you please provide me an idea of step by step solution to it ?

1 Like

If you’re using Rush to compile your extension so no need to compile the R.java separately. Otherwise you need to compile the R.java to a .jar (R.jar) file to use.

So if I’m using rush
I need to add classes.jar and R.java to the deps folder directly or what ?

1 Like

For Rush:

  1. Add the classes.jar to the deps
  2. Place the R.java under the src folder.
  3. Make sure about the package name and its subdirectories of the R.java.
1 Like

I won’t suggest you to dive into that if you are new to extension development.

With experience you will learn how to implement workarounds and tweak libraries according to your needs.

2 Likes