Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android dependency is set to compileOnly/provided which is not supported

Tags:

android

gradle

I'm using com.android.tools.build:gradle:3.1.1 with the latest Gradle version (https://services.gradle.org/distributions-snapshots/gradle-4.8-20180417000132+0000-all.zip).

When I use compileOnly dependencies some of them won't compile, some will. E.g.

compileOnly "com.android.support:support-v4:27.1.1"

works perfectly while

compileOnly "com.facebook.stetho:stetho:1.5.0"

gives a compile error:

Android dependency 'com.facebook.stetho:stetho:1.5.0' is set to compileOnly/provided which is not supported

I was under the impression than any dependency can be compileOnly. Nothing indicates otherwise (https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#new_configurations). Both of these libraries have transitive dependencies.

Any help would be greatly appreciated.

like image 287
Emanuel Moecklin Avatar asked Apr 17 '18 23:04

Emanuel Moecklin


2 Answers

As an experiment, I created a new Android Studio 3.1.1 project. Then, I added a lib module to it as a plain Java library module. I could add compileOnly project(":lib") to the app module, and it compiled. I changed the lib module to be an Android library module (apply plugin: 'com.android.library') with a minimum manifest, and now compileOnly project(":lib") gets the error that you do: "Android dependency 'project :lib' is set to compileOnly/provided which is not supported".

Since there were no other material changes in the lib module, the compileOnly limitation is on Android library modules.

My guess is that it is unclear what "compile only" means for manifest entries, resources, assets, etc. So, they officially punted.

I filed an issue, requesting documentation of this limitation. My requests for documentation usually fall on deaf ears.

like image 66
CommonsWare Avatar answered Nov 08 '22 01:11

CommonsWare


At the dawn of "Dynamic feature modules", compileOnly Android library modules could make sense, to allow easy access to the feature module from the base app when it is installed.

That's why I created this feature request: https://issuetracker.google.com/issues/109894265

Feel free to star it and comment with your use cases.

like image 4
Louis CAD Avatar answered Nov 08 '22 03:11

Louis CAD