Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Gradle - What to use instead of compileOnly?

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.

like image 449
Ugurcan Yildirim Avatar asked Oct 27 '17 12:10

Ugurcan Yildirim


People also ask

Is compileOnly deprecated in Gradle?

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

What is compileOnly in Gradle?

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.

What is the difference between compileOnly and implementation?

implementation – required to compile the production source code and are purely internal. They aren't exposed outside the package. compileOnly – used when they need to be declared only at compile-time, such as source-only annotations or annotation processors.

Is Gradle Sync necessary?

Gradle files and your application code need to be synced if any Gradle file changes, for example when updating dependencies or adding new dependencies manually. Android Studio should automatically sync the project with Gradle when you robotify your app (ie make it compatible with Pepper's tablet).


1 Answers

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

like image 144
CommonsWare Avatar answered Oct 08 '22 16:10

CommonsWare