1

Let's say I add the following dependency to my app level build.gradle file:

compile 'com.squareup.retrofit2:retrofit:2.3.0'

How can I check at runtime that a certain dependency exists or not?

Sneh Pandya
  • 7,801
  • 7
  • 33
  • 50
Fouad
  • 840
  • 1
  • 11
  • 30

1 Answers1

2

You would not be able to run the App in the first place, because if the dependency does not exist you can not build the .apk. There is no run-time checking for gradle dependencies.

Murat Karagöz
  • 31,071
  • 13
  • 78
  • 104
  • 1
    What i intend to do is check whether a certain library exists and change the logic accordingly. For example, if retrofit exists do something otherwise fallback to regular httpurlconnection – Fouad Oct 25 '17 at 13:21
  • @Fouad As I said that is not how dependencies are working. If it exist you can build the app else you can not. – Murat Karagöz Oct 25 '17 at 13:23
  • Nevermind, the answer provided by @Nanev is what i was looking for. I will mark his answer as correct answer to help others. – Fouad Oct 25 '17 at 13:24