I am creating a library for android . I want that my module will use the property that are used in main project . As an example I do no want to define minimum SDK version in my module it will take the value whatever it is defined in main project and also my module can use the library that are defined in main project . As an example if my project has okhttp library then my module can use the functionality of okhttp without integrating it separately in module specific gradle file.
Asked
Active
Viewed 896 times
3
-
you have build.gradle file in your library you just put all the dependencies which are required whether it is in the main project or not. – Alok Singh Feb 15 '19 at 05:22
-
Yes I want to use the same gradle file in my module , which is used in my application. – mW3 Feb 15 '19 at 05:44
-
Then you have to write the same dependencies in your library build.gradle file . – Alok Singh Feb 15 '19 at 05:47
-
Thats what I do not want to , I may use the same library in my both module and app and I want to make sure that both my app and module are using the same version of the library . – mW3 Feb 15 '19 at 05:51
-
Then just use single version directory for project like compile "com.android.support:appcompat-v7:${googleAppVersion}" ext { googleAppVersion = '27.1.1' firbaseVersion = '11.4.2' } in build.gradle file. – Alok Singh Feb 15 '19 at 05:52
-
What if the user of that module doesn't have a single version directory ? – mW3 Feb 15 '19 at 05:53
-
You can use it in multiple library module inside your single project. – Alok Singh Feb 15 '19 at 05:55
1 Answers
0
You can use "ext" block in gradle , to define kind of global variables, there you would define the common version numbers, etc. Which you can use in your module's gradle file. There's a blog post regarding this, you would find that useful.
https://segunfamisa.com/posts/android-gradle-extra-properties