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

编程入门 行业动态 更新时间:2024-10-10 09:24:35
本文介绍了在将Android Studio的Gradle插件升级到3.0.1并将Gradle升级到4.1之后,无法复制配置依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我曾经使用此简单的gradle任务将编译"依赖项复制到特定文件夹:

I used to copy 'compile' dependencies to a specific folder using this simple gradle task :

task copyLibs(type: Copy) { from configurationspile into "$project.rootDir/reports/libs/" }

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

But it stopped working just after upgrading my Android project using gradle plugin 3.0.1 for Android Studio and Gradle tool to 4.1. As the dependency configuration 'compile' is now deprecated by developer.android/studio/build/gradle-plugin-3-0-0-migration.html#new_configurations I changed it to 'implementation'. However, I am not able to use my copyLibs task as resolving configuration 'implementation' directly is not allowed as per Gradle build error output :

$ ./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 help.gradle BUILD FAILED in 1s

请参阅以下我当前用于应用程序模块的build.gradle文件:Apply插件:'com.android.application'

See following my current build.gradle file for app module : apply plugin: 'com.android.application'

android { compileSdkVersion 26 defaultConfig { applicationId "newgradle.testingnewgradle" minSdkVersion 21 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support:support-v4:26.1.0' implementation 'com.android.support:design:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' } task copyLibs(type: Copy) { from configurations.implementation into "$project.rootDir/reports/libs/" } build.dependsOn copyLibs

如果我使用编译"功能,则可以使用,但我希望符合此插件的最新建议用法.

If I use 'compile' it works but I would like to be compliant with the latest recommendation on this plugin the usage.

我需要帮助来升级我的copyLibs任务,以便像升级我的环境之前一样工作. 我正在为Android Studio使用Gradle插件2.2.3和Gradle工具2.14.1.

I need help to upgrade my copyLibs task in order to work as before upgrading my enviromment. I was using gradle plugin 2.2.3 for Android Studio and Gradle tool 2.14.1.

推荐答案

而不是使用configurations.implementation,最好的选择是使用: configuration.runtimeClasspath

instead of using configurations.implementation, the best option is to use: configurations.runtimeClasspath

您还可以考虑: compileClasspath 默认

you can also think about: compileClasspath default

更多推荐

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

本文发布于:2023-11-13 11:13:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584209.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:升级到   并将   插件   关系   Studio

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!