【问题标题】:Could not find method compile() for arguments, org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler找不到参数 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 的方法 compile()
【发布时间】:2018-01-16 20:55:15
【问题描述】:

我收到以下错误

错误:(17, 0) 无法在 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 类型的对象上找到参数 [文件集合] 的方法 compile()。

【问题讨论】:

  • 请添加一些描述性信息或 logcat .. @Agha

标签: android android-studio android-gradle-plugin


【解决方案1】:

在导入之前在早期版本的 Android Studio 上完成的项目后,我偶然发现了这个错误。 I. 将您的构建工具版本升级到 3.0.1 或更高版本,以便它识别术语testImplementation , androidTestImplementation, implementation 二、编辑您的 build.gradle 应用程序文件,以便将所有 implementation 替换为 compile 上一页

implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.0.2'
testImplementation 'junit:junit:4.12'
// RecyclerView
implementation 'com.android.support:recyclerview-v7:27.0.2'

现在应该阅读

compile fileTree(dir: 'libs', include: ['*.jar'])

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:27.0.2'
testImplementation 'junit:junit:4.12'

// RecyclerView
compile 'com.android.support:recyclerview-v7:27.0.2'

上面的解决方案会生成一个关于 Aapt 的错误,然后通过在 gradle.properties 文件中添加以下行来修复该错误

android.enableAapt2=false

不知道这是侥幸还是每次都有效

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-29
    • 2022-01-23
    • 2017-10-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-12
    相关资源
    最近更新 更多