Android依赖项设置为不支持的compileOnly

Android依赖项设置为不支持的compileOnly

本文介绍了Android依赖项设置为不支持的compileOnly/provided的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用com.android.tools.build:gradle:3.1.1和最新的Gradle版本( https://services.gradle.org/distributions-snapshots/gradle-4.8-20180417000132+0000-all.zip ).

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).

当我使用compileOnly依赖项时,其中一些将不会编译,而某些会.例如

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

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

完美运行,同时

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

出现编译错误:

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

我给人的印象是,任何依赖都可以被compileOnly处理.除此之外,没有其他指示( https://developer .android.com/studio/build/gradle-plugin-3-0-0-migration.html#new_configurations ).这两个库都具有传递依赖项.

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.

任何帮助将不胜感激.

推荐答案

作为一个实验,我创建了一个新的Android Studio 3.1.1项目.然后,我在其中添加了lib模块作为纯Java库模块.我可以将compileOnly project(":lib")添加到应用模块,然后进行编译.我将lib模块更改为具有最小清单的Android库模块(apply plugin: 'com.android.library'),现在compileOnly project(":lib")收到您执行的错误:"Android依赖项'project:lib'设置为compileOnly/不支持".

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".

由于lib模块中没有其他实质性更改,因此compileOnly限制在Android库模块上.

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.

这篇关于Android依赖项设置为不支持的compileOnly/provided的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 11:34