相关疑难解决方法(0)

将Android Studio的Gradle插件升级到3.0.1并将Gradle升级到4.1后,无法复制配置依赖项

我曾经使用这个简单的gradle任务将'compile'依赖项复制到特定文件夹:

task copyLibs(type: Copy) {
    from configurations.compile
    into "$project.rootDir/reports/libs/"
}
Run Code Online (Sandbox Code Playgroud)

但是在使用gradle plugin 3.0.1 for Android Studio和Gradle工具升级到4.1后,它刚刚升级我的Android项目后停止工作.由于https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#new_configurations现在弃用了依赖配置'compile',我将其更改为'implementation'.但是,我无法使用我的copyLibs任务,因为根据Gradle构建错误输出不允许直接解析配置'implementation':

$ ./gradlew.bat clean build

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:copyLibs'.
> Resolving configuration 'implementation' directly is not allowed

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s …
Run Code Online (Sandbox Code Playgroud)

android android-studio build.gradle android-gradle-plugin gradle-plugin

26
推荐指数
5
解决办法
8916
查看次数