Android Gradle Dependency

I use local aar files for one of our projects and place below Query. I have 2 libraries and 1 application.

2 libraries: 1. TestLib2 2. TestLib1

1 Appendix: 1. Test

I use the aar file created for TestLib2 and reference it using flatDir in TestLib1. I can easily access the functions present in TestLib2.

Now I use the aar file created for TestLib1 and reference it using flatDir in Test. I can only access the functions present in TestLib1. To access TestLib2, I have to add it to the test application as another library.

Thus, the dependency is as follows:

Test |_ TestLib1 |_ TestLib2 

Is this possible with aar files?

Also in the settings.gradle file for TestLib1 I mention that

 include ':app', ':testlib2-debug' 

Where does the application relate to TestLib1

The build.gradle file really does not have any tastes as such, and I don’t even have a restriction on using them as a jar, since it contains only part of the java code.

Any help on this is greatly appreciated.

BR, Jayshil

Update 1: I also tried in build.gradle TestLib1 and Test. Not lucky yet.

 dependencies { compile (name:'testlib2-debug', ext:'aar') { transitive = true; } } 

And for the test application

 compile (name:'testlib1-debug', ext:'aar') { transitive = true; } 
+3
android-gradle build.gradle
source share
1 answer

So, I finally figured out a solution for this. It works for the two-level dependency mentioned above.

Create a jar file for the Lib 2 test.

 task clearJar(type: Delete) { delete 'build/outputs/loggingSDK.jar' } task makeJar(type: Copy) { from('build/intermediates/bundles/release/') into('build/outputs/') include('classes.jar') rename ('classes.jar', 'testlib2.jar') } makeJar.dependsOn(clearJar, build) 

Using the command

 gradle makeJar 

You would have testlib2.jar

Copy this to your TestLib1

Use command

 gradle assemble 

This will create a debug and release version.

Take the debug version and copy it to Test, you can call the TestLib1 function, which in turn calls the TestLib2 function

Hope this helps someone looking for such a solution.

+3
source share

All Articles