这是我的build.gradle(Project: MyProjectName)
文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.1.1"
ext.supportLibVersion = "25.3.0"
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("windows")) {
buildDir = "C:/tmp/${rootProject.name}/${project.name}"
}
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
以下是build.gradle(Module:app)
:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.android.datafrominternet"
minSdkVersion 10
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.1.0'
// TODO (32) Remove the ConstraintLayout dependency as we aren't using it for these simple projects
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7: $kotlin_version"
}
此错误消息:
Error:Unable to find method 'com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()Ljava/util/List;'.
此意外错误的可能原因包括:
答案 0 :(得分:4)
将android studio更新为beta-v5后遇到同样的问题。 检查你的app / gradle。也许你有阻止 - >
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta5'
}
然后在您的app/gradle
和project gradle
中查看gradle插件的版本。
或者尝试将此块添加到app/gradle
的顶部。
答案 1 :(得分:3)
在项目build.gradle文件中,更改为:
ext.kotlin_version = '1.1.2-4'