0

I want to use Firebase and Play services libraries. As far as I understand it is ok to depend on this library and use it's functionality if it's already present on the device or require to download it, but due to the licensing I can not distribute this libraries bundled with my application.

My question:
How do I declare dependency and have 100% certainty that it is not bundled but will be provided on the phone?

Before this way of adding classpath dependency in buildscript was sufficient for me and added dependencies only during compilation:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        classpath 'com.google.gms:google-services:4.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

But unfortunately now it has to be added to the application dependencies in that way (adding do buildscript doesn't work):

dependencies {
  implementation platform('com.google.firebase:firebase-bom:31.1.0')
  implementation 'com.google.firebase:firebase-analytics'
  implementation 'com.google.firebase:firebase-auth'
  implementation 'com.google.firebase:firebase-firestore'
}

I'm new to android development, but as explained here, when we use different gradle dependency declarations we get:

implementation
Gradle adds the dependency to the compile classpath and packages the dependency to the build output.

api
Gradle adds the dependency to the compile classpath and build output.

compileOnly
Gradle adds the dependency to the compile classpath only (that is, it is not added to the build output). This is useful when you're creating an Android module and you need the dependency during compilation, but it's optional to have it present at runtime.

runtimeOnly
Gradle adds the dependency to the build output only, for use during runtime. That is, it is not added to the compile classpath.

Does api dependency solve my problem, as the description doesn't use the word packages ?

Naan
  • 521
  • 1
  • 11
  • 28
  • If I'm mistaken and I can freely distribute firebase/play libraries, I would need a solid reference with explanation – Naan Nov 28 '22 at 08:21
  • Unclear if you are looking for: https://developers.google.com/android/guides/overview and/or https://developers.google.com/android/guides/opensource Also read: [Gradle Implementation vs API configuration](https://stackoverflow.com/q/44413952/295004) – Morrison Chang Nov 28 '22 at 08:34

0 Answers0