1

Here is my build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.payne.simpletestapp"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:support-vector-drawable:27.1.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    api 'com.google.firebase:firebase-auth:16.0.1'

    implementation 'org.osmdroid:osmdroid-android:6.0.1'
    implementation 'org.osmdroid:osmdroid-wms:6.0.1'
    implementation 'org.osmdroid:osmdroid-mapsforge:6.0.1'
    implementation 'org.osmdroid:osmdroid-geopackage:6.0.1'
    api 'com.github.MKergall:osmbonuspack:6.5.1'
}

apply plugin: 'com.google.gms.google-services'

Here is the warning I'm getting in Android Studio:

Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

Is it my compileSdkVersion line that is causing this message? When I first removed all the "compile", randomly changing them for api and implementation (because I have no idea what the difference is), the warning stopped appearing. But some day I integrated a new dependency that used compile and so got the warning again. I thus changing it for an api (for no particular reason) and now I've been unable to get rid of this warning message.

Any ideas how to get rid of it ?

payne
  • 4,691
  • 8
  • 37
  • 85
  • Did you try clean and rebuild? – Dracarys Jul 15 '18 at 22:19
  • Just did it, and I get `WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.` This warning is thus still appearing despite the absence of any `compile` in my gradle... – payne Jul 15 '18 at 22:26
  • restart the IDEA? – Dracarys Jul 15 '18 at 22:29
  • Restarted IDEA; it still displays `Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html` – payne Jul 15 '18 at 22:38

1 Answers1

0

Let's review the difference from API and compile:

  • Implementation:

When your module configures an implementation dependency, it's letting Gradle know that the module does not want to leak the dependency to other modules at compile time. That is, the dependency is available to other modules only at runtime.

  • API

When a module includes an api dependency, it's letting Gradle know that the module wants to transitively export that dependency to other modules, so that it's available to them at both runtime and compile time.

(from https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration?utm_source=android-studio#new_configurations)

API behaves exactly like compile did. If you don't want to bother with implementation, use API.

Implementation is a bit trickier and iirc it will only allow your dependencies to be used at runtime and not compile time. You can remplace the imports by implementation, and if the project fails building, replace it by api.

The warning is likely from a dependency you have, that in turns also has dependencies, which are referred as compile. Try to update the version of your dependencies, maybe you are using an older version that has not updated their gradle build file.

Samuel Yvon
  • 416
  • 5
  • 13
  • What exactly is a "module" in this context? What would be a concrete example of when selecting between `api` and `implementation` is critical? Lastly, so far I assumed Android Studio did a pretty good job at checking out if I was using the latest version of a dependency by highlighting the old ones and mentioning the latest version. – payne Jul 16 '18 at 02:51
  • 1
    A module would be a piece of code that is built separately from your project, so dependencies for instance. I believe android studio warns you about deprecated but I am not sure for older versions. Either way that doesnt mean that your dependencies script have switched from compile to API / implementation. It also affects subdependencies that themselves might not be updated. As for an exemple of the use of implementation and api, check this SO post :https://stackoverflow.com/a/44419574/5092307 – Samuel Yvon Jul 16 '18 at 11:42