如何解决找不到参数的方法 compile() [文件集合]

编程入门 行业动态 更新时间:2024-10-23 04:50:43
本文介绍了如何解决找不到参数的方法 compile() [文件集合]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我将一个项目导入到 Android Studio,但该项目没有被构建.我得到的错误信息是:

错误:(20, 0) 找不到参数的方法 compile() [文件集合]在类型对象上org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.<a href="openFile:C:\Users\xxx\AndroidStudioProjects\WSAppAndroid\build.gradle">打开文件</a>

如下面的图 1 所示,在 gradle.build(项目)中,我在依赖项部分有这些库.

我用谷歌搜索了如何解决这个问题,我发现的帖子中有

build.gradle(项目):

//顶级构建文件,您可以在其中添加常见的配置选项所有子项目/模块.构建脚本{存储库{jcenter()MavenCentral()}依赖{类路径 'com.android.tools.build:gradle:2.3.0'类路径 'com.neenbedankt.gradle.plugins:android-apt:1.7'//1.8?}}所有项目{存储库{jcenter()MavenCentral()}}依赖{编译文件('gradle/wrapper/gradle-wrapper.jar')编译文件('app/libs/android-viewbadger.jar')编译文件('app/libs/iDappsImagesLib_v0.2.jar')编译文件('app/libs/iDappsToolsLib_v0.1.jar')编译'com.android.support:support-v4:25.2.0'}

compile-on-org-gradle-api-internal-artifacts-dsl-depen/33991915#33991915

解决方案

compile 已在较新版本的 gradle 中替换为 implementation,将 build.gradle 文件中的 compile 替换为 implementation 并将 compile group 替换为 implmenetation group.

I imported a project into Android Studio, but the project is not getting built. the error message I get is:

Error:(20, 0) Could not find method compile() for arguments [file collection]  
on object of type 
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

<a href="openFile:C:\Users\xxx\AndroidStudioProjects\WSAppAndroid 
\build.gradle">Open File</a>

As shown in image-1 posted below, in gradle.build (project) I have these libraries in the dependencies section.

I googled how to solve this issue and among the posts I found was this one which tackles the same problem. But the accepted answer does not solve the problem i have.

As an attempt to solve this issue, can I use compile instead of compile files in build.gradle? how it can be done? my question is

image-1

build.gradle (project):

// Top-level build file where you can add configuration options common to  
all sub-projects/modules.

buildscript {
repositories {
    jcenter()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.0'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7' // 1.8?
}
}
allprojects {
repositories {
    jcenter()
    mavenCentral()
}
}

dependencies {
compile files('gradle/wrapper/gradle-wrapper.jar')
compile files('app/libs/android-viewbadger.jar')
compile files('app/libs/iDappsImagesLib_v0.2.jar')
compile files('app/libs/iDappsToolsLib_v0.1.jar')
compile 'com.android.support:support-v4:25.2.0'
}

compile-on-org-gradle-api-internal-artifacts-dsl-depen/33991915#33991915

解决方案

compile has been replaced by implementation in newer version of gradle, replace compile with implementation and compile group with implmenetation group in your build.gradle file.

这篇关于如何解决找不到参数的方法 compile() [文件集合]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-23 02:59:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1034435.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   如何解决   参数   文件   方法

发布评论

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

>www.elefans.com

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