Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle sync Error on Android Studio 3.1 Canary 3

Hey fellows after update Android Studio to 3.1 Canary 3 I've just created fresh project but gradle synchronization failed due:

Error:com.android.tools.idea.gradle.project.model.AndroidModuleModel.getMainArtifact()Lcom/android/tools/idea/gradle/project/model/ide/android/IdeAndroidArtifact;com.android.tools.idea.gradle.project.model.AndroidModuleModel.getMainArtifact()Lcom/android/tools/idea/gradle/project/model/ide/android/IdeAndroidArtifact;

My gradle file is:

> buildscript {
>     ext.kotlin_version = '1.2.0-rc-39'
>     repositories {
>         google()
>         jcenter()
>         maven { url "https://dl.bintray.com/kotlin/kotlin-dev"}
>     }
>     dependencies {
>         classpath 'com.android.tools.build:gradle:3.1.0-alpha03'
>         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
>         classpath 'com.google.gms:google-services:3.1.0'
>     } }
> 
> allprojects {
>     repositories {
>         google()
>         jcenter()
>         maven { url "https://dl.bintray.com/kotlin/kotlin-dev"}
>     } }
> 
> task clean(type: Delete) {
>     delete rootProject.buildDir }
> 

And the second build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {

    compileSdkVersion 27
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "xxx"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "0.0.1"
        setProperty("archivesBaseName", "xxx v$versionName")
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true

        buildConfigField 'String', 'apiEndpointUrl', '"https://xxx.xxx.xxx"'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

ext {
    supportLibrary = '26.1.0'
    playServices = '11.2.2'
    androidLifecycle = '1.0.0-alpha9'
    androidLifecycleCompiler = '1.0.0-alpha8'
    jackson = '2.9.0'
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

    // RxJava
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.1'
    implementation 'io.reactivex.rxjava2:rxkotlin:2.1.0'

    // Retrofit
    implementation 'com.squareup.okhttp3:okhttp:3.8.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'

    implementation 'com.squareup.retrofit2:converter-jackson:2.3.0'
    implementation "com.fasterxml.jackson.core:jackson-core:${jackson}"
    implementation "com.fasterxml.jackson.core:jackson-annotations:${jackson}"
    implementation "com.fasterxml.jackson.core:jackson-databind:${jackson}"

    // Google Play / Firebase services
    implementation 'com.google.android.gms:play-services-maps:11.6.0'

    // Widgets / Views
    implementation "com.android.support:appcompat-v7:$supportLibrary"
    implementation "com.android.support:design:${supportLibrary}"
    implementation "com.android.support:support-v4:${supportLibrary}"
    implementation "com.android.support:cardview-v7:${supportLibrary}"
    implementation "com.android.support:recyclerview-v7:${supportLibrary}"
    implementation "com.android.support:support-vector-drawable:${supportLibrary}"
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'

    // EventBus
    implementation 'org.greenrobot:eventbus:3.0.0'

    //    Android Architecture
    implementation "android.arch.lifecycle:runtime:${androidLifecycle}"
    implementation "android.arch.lifecycle:extensions:${androidLifecycle}"
    annotationProcessor "android.arch.lifecycle:compiler:${androidLifecycleCompiler}"
    kapt "android.arch.lifecycle:compiler:${androidLifecycleCompiler}"

    // Room - DB ORM
    implementation "android.arch.persistence.room:runtime:$androidLifecycle"
    implementation "android.arch.persistence.room:rxjava2:${androidLifecycle}"
    annotationProcessor "android.arch.persistence.room:compiler:${androidLifecycleCompiler}"
    kapt "android.arch.persistence.room:compiler:${androidLifecycleCompiler}"
}
like image 560
murt Avatar asked Nov 14 '17 20:11

murt


People also ask

How do I fix Gradle project sync failed?

Here is the full error, “ Gradle Project Sync Failed. Basic functionality (e.g. editing, debugging) will not work properly “. Disable and Re-enable Android Repository option. (Sometime, it may also show you red symbol error.) Once loading complete, click on Apply and OK.

What are the issues with Android Gradle plugin?

Known issues with the Android Gradle Plugin 1 Lint exceptions in Kotlin projects. Set the environment variable LINT_DO_NOT_REUSE_UAST_ENV to true. ... 2 Missing Manifest class. ... 3 Signing file named with Carriage Return (CR) characters. ... 4 API changes. ...

Why is my Gradle daemon not syncing?

If it is set to Control+Space, change it to Super+Space, or another shortcut of your choice. This section describes known issues related to project configuration and Gradle sync. The issue is that the Gradle daemon is trying to use IPv4 instead of IPv6.

Should I update Android Gradle plugin to KMM?

We recommend the update, but if you cannot update to KMM plugin 1.5.0, you can continue using Android Gradle plugin 4.2.x with Android Studio Arctic Fox. For more information, see KT-43944. There is no lint text output printed to stdout when the lint task is UP-TO-DATE ( issue #191897708 ).


2 Answers

Same problem here. Uninstalling the Kotlin plugin (Preferences > Plugins > Kotlin > Uninstall) and using the version that comes with the IDE solved the problem for me.

like image 165
harry248 Avatar answered Sep 29 '22 12:09

harry248


open settings dialog, then select plugins & search for kotlin & uninstall it, restart the Android Studio and upgrade the Gradle if prompted.

like image 41
Tonnie Avatar answered Sep 29 '22 12:09

Tonnie