现在考虑这个解决方案已经太久了,我不确定我是否错过了它或只是错误输入了一些内容,但我的Gradle脚本无法编译.我正在迁移到Gradle,我很新.我非常习惯使用Maven进行依赖管理,但Gradle现在看起来最好.从运行此代码片段:
dependencies {
compile group: 'org.bukkit', name: 'bukkit', version: '1.7.9-R0.1-SNAPSHOT'
compile('io.ibj:MattLib:1.1-SNAPSHOT') {
exclude group: 'de.bananaco'
exclude 'net.milkbowl:vault:1.2.27'
}
compile group: 'net.citizensnpcs', name: 'citizens', version: '2.0.12'
compile group: 'com.sk89q', name: 'worldedit', version: '5.6.1'
compile group: 'com.sk89q', name: 'worldguard', version: '5.9'
compile group: 'net.milkbowl', name: 'vault', version: '1.2.12'
compile fileTree(dir: 'libs', includes: ['*.jar'])
}
Run Code Online (Sandbox Code Playgroud)
注意:我确实应用了java,maven,nexus,shadow和rebel插件.
当我运行Gradle任务时,遇到此错误:
Could not find method compile() for arguments [[io.ibj:MattLib:1.1-SNAPSHOT], build_1b5iofu9r9krp7o8mme0dqo9l$_run_closure2_closure8@66fb45e5] on root project 'project'
Run Code Online (Sandbox Code Playgroud)
如果我从项目中删除"MattLib"依赖项并将其重新插入
compile 'io.ibj:MattLib:1.1-SNAPSHOT'
Run Code Online (Sandbox Code Playgroud)
该脚本完成,但我有依赖性问题.我在这里读到:
dependencies {
compile("org.gradle.test.excludes:api:1.0") {
exclude module: 'shared'
}
} …Run Code Online (Sandbox Code Playgroud) 我有一个基于gradle的Android项目,包含4个子模块 - 两个库和两个应用程序.我试图通过将一些共享代码/配置移动到顶级build.gradle文件来简化每个子模块的build.gradle文件,并用于subprojects {}使每个子模块都可以使用该代码.
文件系统结构如下所示:
Root
|- App1/
|- App2/
|- Lib1/
|- Lib2/
|- build.gradle
|- settings.gradle
Run Code Online (Sandbox Code Playgroud)
问题是,如果我android {}向子项目添加一个部分,那么gradle任务就会失败.例如,这是我的顶级build.gradle文件:
subprojects { project ->
android {
buildToolsVersion "20.0.0"
}
}
Run Code Online (Sandbox Code Playgroud)
运行gradle返回:
出了什么问题:评估根项目'android'时出现问题.无法在根项目'android'上找到参数[build_7dngpra6ldok366maq0on77r7e $ _run_closure3_closure5 @ 43d95624]的方法android().
我搜索了类似的帖子,有些人建议在apply plugin: 'android'每个子项目中添加该行,以揭示android()gradle抱怨的缺失方法.但是,该解决方案对我不起作用,因为它会有效地将该行添加到库项目中,而这需要apply plugin: 'android-library'相反.
当你在同一个项目中有应用程序和库时,有没有办法在android {}里面使用subprojects {}?
我正在使用Android Studio 2.0,当发生奇怪的事情时,我正试图运行我的程序.我运行了gradle的build命令,我收到了这个错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lint'.
> Lint found errors in the project; aborting build.
Fix the issues identified by lint, or add the following to your build script to proceed with errors:
...
android {
lintOptions {
abortOnError false
}
}
...
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total …Run Code Online (Sandbox Code Playgroud) android gradle android-studio android-gradle-plugin android-studio-2.0
我正在尝试在我的android工作室项目上进行成绩同步,并且我在标题中不断收到此错误.我的build.gradle文件是
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
compileSdkVersion 24
buildToolsVersion '24.0.0'
}
dependencies {
}
Run Code Online (Sandbox Code Playgroud)
我的错误信息是
Gradle sync failed: Could not find method android() for arguments …Run Code Online (Sandbox Code Playgroud) 得到一个bug,当我尝试在工作室中编译我的项目时,我已经搜索了很多而没有真正的解决方案
错误:(17,0)无法在类型为org.gradle.api.Project的根项目'booksStudioDir'中找到参数[build_a7zf1o8ge4ow4uolz6kqzw5ov $ _run_closure2 @ 19201053]的方法android().
这是我的构建/ gradle文件的示例
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 21
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.peade.time"
minSdkVersion 10
targetSdkVersion 13
}
signingConfigs {
release {
storeFile file("/home/bestman/Desktop/mkey/key")
storePassword "androidkeys"
keyAlias "peade"
keyPassword "yes1234"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
}
}
}
repositories {
maven { url 'https://maven.fabric.io/public' } …Run Code Online (Sandbox Code Playgroud)