更新到版本4.10后,Android Gradle Sync失败

时间:2019-02-18 19:19:53

标签: android gradle

将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']
}

,然后应用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'
        }
    }
}

1 个答案:

答案 0 :(得分:0)

升级您的Kotlin插件。

简单方法(推荐)。

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

手动(如果需要)。

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

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

3)重新启动Android Studio。