256

So I'm reading Android 6 for Programmers: An App-Driven Approach and the first two app examples I had no issues with the examples, this time the FlagQuiz example when loaded in Android Studio 3.0 Canary-3 I'm getting this error which isn't letting me build the project:

Error: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.

You can download the source from the book site here to test with the same code base that I'm testing from.

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
exts
  • 9,788
  • 4
  • 19
  • 21

9 Answers9

660

Alright I figured out how to fix this issue.

  • 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.

Rakan Habab
  • 101
  • 2
  • 12
exts
  • 9,788
  • 4
  • 19
  • 21
  • 145
    I really don't understand why Google makes things harder. – ACAkgul Dec 07 '17 at 21:37
  • 1
    @AhmetCanAkgül It doesn't !! – Masquerade Dec 14 '17 at 02:48
  • 2
    in my case classpath 'com.android.tools.build:gradle:2.3.2' working. – Prags Jan 03 '18 at 07:58
  • It certainly is a bit of a chore. – Scott Fraley Jan 03 '18 at 23:13
  • 14
    @ACAkgul Yep, we are updating our apps less often now, every time we do this is a massive chore, a simple bug fix means we have to update our environment and spend hours (if not days) to switch to new APIs and environment. People make fun of Microsoft, now I think MS are angels! – albattran Jan 21 '18 at 16:55
  • I had an old project that I needed to update and ran into this issue. This solution worked perfectly. – Wayne Johnson Feb 20 '18 at 02:40
  • You don't really need to do any of this it's only to satisfy Android Studio. You can simply do a gradle build from the command line `./gradlew assembleRelease` without changing anything in your config files. – David Mar 29 '18 at 20:39
  • 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:3.3**' – Marwan Salim Jun 04 '18 at 06:36
  • I hope there is a shortcut. – Sunil Kumar Aug 01 '18 at 12:57
  • Solution from srs takes less time. – Sunil Kumar Aug 01 '18 at 15:10
  • Got into same issue and all the above steps shared went well. But finally at the end, got stuck with below error: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html – kamleshrao Sep 17 '18 at 14:08
  • After following above steps, stuck in **ERROR**: Failed to resolve: com.android.support:appcompat-v7:22.1.1 **Add Google Maven repository and sync project** **Show in Project Structure dialog** **Affected Modules: app** – Dharmik Oct 20 '19 at 15:54
  • What's even the point of gradlew if I'm forced to update... – Aurasphere Jul 13 '20 at 17:36
  • ****I really don't understand why Google makes things harder*** this is NOT the problem with google/android only. That is a malady that has happened to the world. The tech-world has become art-less and hence heartless, senseless, modesty-less, android dev, it will download a 1000 files to say hello world and still cry something is NOT found – Padmanabhan Feb 14 '21 at 06:22
91

For Android Studio 3 I need to update two files to fix the error:--

1. app/build.gradle

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

2. app/gradle/wrapper/gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
srs
  • 2,521
  • 16
  • 16
  • This worked for me. Should be marked as correct answer. – Tina J Jan 29 '18 at 22:05
  • 1
    @srs, please explain why in dependencies block gradle version 3.0.1, but in gradle-wrapper file 4.1? Shouldn't it be the same version? – Johnny Five May 06 '18 at 18:23
  • 1
    Interesting, but couldn't do this in really old project. Then I just changed gradle version not to 3.0.1 but to 2.2.1 and it worked. – Johnny Five May 06 '18 at 18:36
49

First, open your application module build.gradle file.

Check the classpath according to your project dependency. If not change the version of this classpath.

from:

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

To:

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

or higher version according to your gradle of android studio.

If its still problem, then change buildToolsVersion:

From:

buildToolsVersion '21.0.0'

To:

buildToolsVersion '25.0.0'

then hit 'Try again' and gradle will automatically sync. This will solve it.

amit pandya
  • 1,384
  • 13
  • 22
16

In my case, Android Studio 3.0.1, I fixed the issue with the following two steps.

Step 1: Change Gradle plugin version in project-level build.gradle

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

Step 2: Change gradle version

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Pang
  • 9,564
  • 146
  • 81
  • 122
Harry Zhang
  • 799
  • 9
  • 6
11

I also faced the same issue and got a solution very similar:

  1. Changing the classpath to classpath 'com.android.tools.build:gradle:2.3.2'

    Image after adding the classpath

  2. A new message indicating to Update Build Tool version, so just click that message to update. Update

Girish B.R
  • 493
  • 5
  • 8
10

Change your gradle version or update it

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
}

alt+enter and choose "replace with specific version".

Pang
  • 9,564
  • 146
  • 81
  • 122
Exel Staderlin
  • 535
  • 7
  • 10
5

You can do this by changing the gradle file.

 build.gradle > change
    dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
    }
    gradle-wrapper.properties > update
    distributionUrl=https://services.gradle.org/distributions/gradle-4.6-all.zip
Mudassir Khan
  • 1,714
  • 1
  • 20
  • 25
0

If this ()Unsupported method: BaseConfig.getApplicationIdSuffix Android Project is old and you have updated Android Studio, what I did was simply CLOSE PROJECT and ran it again. It solved the issue for me. Did not add any dependencies or whatever as described by other answers.

itzo
  • 1,220
  • 14
  • 18
-1

I did the following to make this run on AS 3.5

  1. app/ build.gradle

    apply plugin: 'com.android.application'

    android { compileSdkVersion 21 buildToolsVersion "25.0.0"

    defaultConfig {
        applicationId "com.example.android.mobileperf.render"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    

    }

dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:21.0.0' implementation 'com.squareup.picasso:picasso:2.71828' }

  1. build.gradle

    buildscript { repositories { jcenter() mavenCentral() maven { url 'https://maven.google.com/' name 'Google' } google() } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' } } allprojects { repositories { jcenter() google() } }

  2. gradle-wrapper.properties

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

Hermandroid
  • 2,120
  • 4
  • 29
  • 35