36

According to the following SO post, compile has become implementation recently: What's the difference between implementation and compile in gradle

My question is what should I use instead of compileOnly? The post above does not address that gradle config. I do know that I can still use compileOnly but what is the recommended config that will not be deprecated soon?

It seemed like all configs that contain ..compile.. would be replaced by ..implementation... I tried implementationOnly but not accepted by Android Studio.

Ugurcan Yildirim
  • 5,440
  • 2
  • 35
  • 66
  • Not all `..compile..` would be replaced by `..implementation..` such as `api`. – CoXier Oct 27 '17 at 12:32
  • 1
    You can extend your question with this "I don't have compile statement in my dependency. Even thou, when the application is building, the error is still there: 'compile' is obsolete...", if that is also the problem. – Abhinav Saxena Jan 14 '19 at 09:17

3 Answers3

55

compileOnly is the replacement — the equivalent configuration that is being deprecated is provided. See the documentation.

CommonsWare
  • 954,112
  • 185
  • 2,315
  • 2,367
  • 1
    I don't have compile statement in my dependency. Even thou, when the application is building, the error is still there: 'compile' is obsolete... – Abhinav Saxena Jan 14 '19 at 09:15
  • 1
    @CommonsWare : Every day I'm getting benefited because of you. Thanks a lot for your contributions :-) – Tom Taylor Oct 07 '19 at 12:53
3

Your Project gradle dependecies should be changed from

dependencies {
    provided 'com.someDependency:api:78'
}

to

dependencies {
    compileOnly 'com.someDependency:api:78'
}
Alex Myers
  • 5,068
  • 7
  • 21
  • 35
Lone Ronin
  • 1,940
  • 15
  • 28
0

There is a case when you accept IDE automatic suggest to add project to your gradle file, it will add "compile project(path: 'xxx')". Correct it and you'll be fine.

Brian Chu
  • 93
  • 9