Could not find method android() for arguments when building Android project from gradle

本文提供了一种解决方案来解决在使用Gradle构建Android项目时出现的'Could not find method android for arguments'错误。通过在根项目的build.gradle文件中定义编译SDK版本和构建工具版本,并在所有Android模块中引用这些值,可以避免此问题。值得注意的是,这种方法在旧版本的Gradle中可能不起作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://stackoverflow.com/questions/26243480/could-not-find-method-android-for-arguments-when-building-android-project-from


The proposed solution is:

...in the root project's build.gradle:

ext {
  compileSdkVersion = 19
  buildToolsVersion = "19.0.1"
}

in all the android modules:

android {
  compileSdkVersion rootProject.ext.compileSdkVersion
  buildToolsVersion rootProject.ext.buildToolsVersion
}

...

One think I noticed was that this doesn't work on older versions of gradle (I was trying with 1.10 and got an error). With Gradle 2.1 this seems to work correctly though.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值