【问题标题】:Android Gradle Sync Failure after updating to version 4.10更新到版本 4.10 后 Android Gradle 同步失败
【发布时间】:2019-02-18 19:19:52
【问题描述】:

将 AndroidStudio、Gradle 和 com.android.tools.build:gradle 更新到新版本后,我收到此错误:

org/jetbrains/kotlin/kapt/idea/KaptGradleModelorg/jetbrains/kotlin/kapt/idea/KaptGradleModel

gradle.properties:

#Mon Feb 18 21:35:48 IRST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

项目 Gradle:

buildscript {
    ext.kotlin_version = '1.3.21'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
        classpath 'com.novoda:bintray-release:0.9'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}


ext {
    VERSION = version()
}

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


task version {
    println version()
}

def String version() {
    def versionPropsFile = file('version.properties')
    def Properties versionProps = new Properties()
    versionProps.load(new FileInputStream(versionPropsFile))

    return versionProps['major'] + "." + versionProps['minor'] + "." + versionProps['patch']
}

然后是 app gradle:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.jakewharton.hugo'
apply plugin: 'com.novoda.bintray-release'

android {
    compileSdkVersion 28

    defaultConfig {
        applicationId "xxx.xxxxxxx.xxxxxxxxxxxx"
        minSdkVersion 21
        versionCode 1
        versionName "1"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled = true
    }

    dataBinding {
        enabled = true
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/rxjava.properties'
    }

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

【问题讨论】:

  • 请提供错误日志。
  • @FaysalAhmed 应用程序无法运行,我在构建过程中只得到这样的结果:org/jetbrains/kotlin/kapt/idea/KaptGradleModelorg/jetbrains/kotlin/kapt/idea/KaptGradleModel
  • 能否请您尝试删除 Kotlin 插件并重新同步?
  • 你好@DolDurma,你解决了这个问题吗?我也面临同样的问题:(
  • @ppreetikaa 这是你的answer

标签: android gradle


【解决方案1】:

升级您的 Kotlin 插件。

简单的方法(推荐)。

Double shift -> Plugins -> Updates -> search Kotlin -> Update! -> Restart AS

手动方式(如果需要)。

1) 从此链接手动下载 Kotlin 插件。

2) Double shift -> 插件 -> (设置) 图标 -> 从磁盘安装 -> 选择该插件。

3) 重启 Android Studio。

【讨论】:

    猜你喜欢
    • 2019-07-02
    • 2019-07-18
    • 1970-01-01
    • 2016-08-08
    • 1970-01-01
    • 1970-01-01
    • 2019-01-22
    • 2018-09-05
    • 2019-09-13
    相关资源
    最近更新 更多