如何在Anko中调试“无法解决com.google.android:android”错误

时间:2017-05-23 02:18:39

标签: android kotlin

compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
//Anko
compile "org.jetbrains.anko:anko:$anko_version"
compile "org.jetbrains.anko:anko-coroutines:$anko_version"
compile "org.jetbrains.anko:anko-appcompat-v7:$anko_version"
compile 'org.jetbrains.kotlinx:kotlinx-coroutines-android:0.13'

Build error:

Error:Failed to resolve: Could not resolve    
 com.google.android:android:2.3.1.

Required by:  
    project :app > org.jetbrains.kotlinx:kotlinx-coroutines-android:0.13

3 个答案:

答案 0 :(得分:1)

安装Android Studio 2.4 Preview时遇到同样的错误。只需确保,您的项目级build.gradle看起来像这样

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = '1.1.2-3'
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1' //Version must be exactly 2.3.1
        classpath 'com.google.gms:google-services:3.0.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

答案 1 :(得分:0)

删除行

compile "org.jetbrains.anko:anko-coroutines:$anko_version"
请再试一次。 或者粘贴完整的build.gradle。

答案 2 :(得分:0)