我曾经使用此简单的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之后,无法复制配置依赖关系
发布评论