android studio'-d'选项与目录目标被忽略,因为指定了'-Xbuild-file'

时间:2018-05-15 13:16:52

标签: android android-studio kotlin android-jetpack

我是Android开发新手,刚刚在本教程中创建了我在android studio 3.2(canary)中的第一个“hello world”项目。 https://developer.android.com/jetpack/docs/getting-started

然后我就做了Build-> make project project试图构建并给我以下错误。

  

无法为org.gradle.api.Project类型的根项目'JetpackHelloWorld'获取未知属性'archLifecycleVersion'。

但是我能够在我发布的问题的答案的帮助下解决这个错误。 android jetpack project gives archlifecycleversion build error

在错误解决之后我再次尝试构建,现在我遇到以下错误。

  

忽略目录目标的'-d'选项,因为指定了'-Xbuild-file'

更新

Build.gradle (应用程序文件夹级别)

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.touseef.jetpackhelloworld"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

build.gradle (项目级别)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.41'
repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.0-alpha14'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

禁用运行

正如你在屏幕截图中看到的那样,应用程序的运行选项被禁用,如果我点击下拉列表,它会要求我编辑配置,我应该在空项目中执行哪种配置?

run disabled

2 个答案:

答案 0 :(得分:0)

在使用Kotlin版本1.2.61构建项目时,我遇到了同样的问题,在将版本从1.2.71更新为1.2.61后,它起作用了

classpath依赖项是(在项目级别build.gradle内部):

dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0-alpha10'
        classpath 'com.google.gms:google-services:4.0.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71"
        classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha06"
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:1.2.71"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

答案 1 :(得分:0)

由于某种原因,问题在于在Kotlin编译器的设置中激活了增量编译。如果禁用这些选项,则不会收到警告。