无法构建 Kotlin 项目:无法解析所有配置文件 [英] couldn't building Kotlin project:Could not resolve all files for configuration

查看:32
本文介绍了无法构建 Kotlin 项目:无法解析所有配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次尝试在 Android Studio 中使用 Kotlin.我更新了 Android Studio,但是当我尝试构建项目时,收到错误消息贴在下面.我试图通过遵循一些答案来解决它,但他们无法解决问题.

I am trying to use Kotlin for first time in Android Studio. I updated Android Studio, but when I tried to build the project, I received the error message posted below. I tried to solve it by following some answers, but they could not solve the issue.

我试图通过在依赖项中添加以下行来解决这个问题:

I tried to solve this issue by adding the following line to dependencies:

        classpath "org.jetbrains.kotlin:kotlin-stdlib-jdk8"

但它无法解决它.

请看一下构建文件,请告诉我如何解决

please have a look at build file, and please let me know how to solve

构建错误:

org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration 
':classpath'.
Cause 1: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.jetbrains.kotlin:kotlin-reflect:1.2.61.

gradle 项目:

buildscript {
ext.kotlin_version = '1.1.1'
repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.4'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath "org.jetbrains.kotlin:kotlin-stdlib:$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
}

gradle 应用:

apply plugin: 'com.android.application'

android {
compileSdkVersion 26

defaultConfig {
    applicationId "com.example.pc_amr.snakegame_01.app"
    minSdkVersion 19
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
}

buildTypes {
   release {
       minifyEnabled false
       proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
   }
}

}

dependencies {
implementation project(':feature')
implementation project(':base')
}

更新:

after adding that line to gradle.app:
    apply plugin: 'com.android.application'
i received the following error:

Unable to find method 'com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()Ljava/util/List;'.
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)</li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)</li><li>Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.</li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

please note that, 
    ext.kotlin_version = '1.1.1'
and kotlin version in Android Studio is:
    version 1.2.61

推荐答案

在你的 build.gradle(app) 之上添加这个

Add this on top of your build.gradle(app)

apply plugin: 'kotlin-android'

并在项目gradle中设置ext.kotlin_version = '1.2.61'

and set ext.kotlin_version = '1.2.61' in project gradle

这篇关于无法构建 Kotlin 项目:无法解析所有配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆