1

Gradle project sync failed and did not get answers from other related questions. Here are the details of my situation.

Initial sync attempt yielded the following error message:

Unsupported method: BaseConfig.getApplicationIdSuffix().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.

I have Android Studio 3.0. The build.gradle file includes the following dependency:

classpath 'com.android.tools.build:gradle-experimental:0.2.1'

  The gradle-wrapper.properties file includes the following distribution URL:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip

According to https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#update_gradle I need to make some changes.
First, update the Gradle version for Android Studio 3.0 in gradle-wrapper.properties:

distributionUrl=\   https://services.gradle.org/distributions/gradle-4.1-all.zip (I believe the backslash right after the equal sign is an error and did not make that change.)

Second, add the following buildscript repository to build.gradle:

google()

Third, change the build.gradle dependency:

classpath 'com.android.tools.build:gradle:3.0.1'

The second and third changes apply the latest version of the Android plug-in.

When I try to sync after these changes it fails again with the following new error:

Plugin with id 'com.android.model.application' not found.

The error refers to the first line of build.gradle:

apply plugin: 'com.android.model.application'

What is happening and why? I recently added NDK to Android Studio. The project I'm trying to sync includes C code. I'm not completely certain I added NDK correctly. I wonder if that could be part of the problem.

  • does creating a new project syncs successfully? – Nixon Kosgei Dec 5 '17 at 16:44
  • Yes, it appears to sync correctly, but a regular project did not set up for C code. So I tried it with "C++ support enabled". That also appeared to sync correctly. I'm concerned again that it's an issue with my NDK setup. How do I start a new project with C instead of C++ support? – tsk Dec 6 '17 at 19:34
2

First, the gradle-wrapper.properties is incorrect. You must include \ in it. It should be something like this:

#Sat Jun 17 17:47:18 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

Then, add the experimental classpath to project build.gradle. Something like this:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle-experimental:0.7.0-alpha4"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Check the Experimental Plugin User Guide for details.

|improve this answer|||||
  • 1
    Thanks. According to a link in the guide I think an appropriate gradle plug-in version is 0.11.0-alpha-preview-02. I changed the build.gradle line to this. Sync yielded an error indicating this plug-in requires gradle 4.0, not 4.1. I changed the gradle-wrapper properties line to 4.0. Sync then seemed to proceed much further, but I get yet another error. Cannot set readonly property: proguardFiles for class: com.android.build.gradle.managed.BuildType What is this error indicating? – tsk Dec 5 '17 at 23:16
2

Go to your build.gradle version or update it

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
}
|improve this answer|||||
1

You should change you dependencies classpath

All steps are here :

  • Open build.gradle and change the gradle version to the recommended version:
    classpath 'com.android.tools.build:gradle:1.3.0' to
    classpath 'com.android.tools.build:gradle:2.3.2'
  • Hit 'Try Again'
  • In the messages box it'll say 'Fix Gradle Wrapper and re-import project' Click that, since the minimum gradle version is 3.3
  • A new error will popup and say The SDK Build Tools revision (23.0.1) is too low for project ':app'. Minimum required is 25.0.0 - Hit Update Build Tools version and sync project
  • A window may popup that says Android Gradle Plugin Update recommended, just update from there.

Now the project should be runnable now on any of your android virtual devices.

|improve this answer|||||
0

Make sure your Gradle version is compatible with your Android Gradle Plugin.

https://stackoverflow.com/questions/24795079

https://developer.android.com/studio/releases/gradle-plugin#updating-gradle

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.