得到一个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' } mavenCentral() } dependencies { compile 'com.edmodo:cropper:1.0.1' compile 'com.android.support:support-v4:21.0.3' compile 'com.itextpdf:itextpdf:5.5.6' // compile files('libs/commons-lang3-3.3.2.jar') compile files('libs/dropBox-android-sdk-1.6.1.jar') // compile files('libs/httpmime-4.0.3.jar') compile files('libs/json_simple-1.1.jar') compile files('libs/picasso-2.5.2.jar') compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') { transitive = true; } compile project(':owncloud') }
解决方法
有两个build.gradle文件.一个是顶级持有者,另一个是模块持有者.
以下是一个例子.
顶级build.gradle:
https://github.com/nickbutcher/plaid/blob/master/build.gradle
module的build.gradle:
https://github.com/nickbutcher/plaid/blob/master/app/build.gradle
android块应该在module的build.gradle中.我猜你必须在顶级build.gradle中定义了android块,这导致了错误.