0

I tried to import android.support.design.widget.TabLayout, but I got cannot resolve symbol 'design' error. enter image description here

In the First I sought that is a problem with a implementation com.android.support:design version (in gradle Module). But it is not. I managed to find the cause of this error - dependencies versions (in gradle Project).

My dependencies version is:

classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.google.gms:google-services:4.3.3

'

So if I use older version - this is fixing the error.

classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.2.1'

I do not understand why It does not work with newest versions. Please help me understand this, why I cannot use new versions.

My android studio vesrion is: 4.0

gradle Module:

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"

defaultConfig {
    applicationId "mv.group.qwerty"
    minSdkVersion 23
    targetSdkVersion 29
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
   

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

gradle Project:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.0'
        classpath 'com.google.gms:google-services:4.3.3'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}
2
  • why you use classpath instead of usual implementation? Commented Sep 27, 2020 at 7:33
  • Hi Marcin, First reason: because firebase suggest to use classpath and any YouTube tutorials. Second reason: if I using implementation instead of classpath I got next errors: (1) Gradle DSL method not found: 'implementation()' Possible causes: The project 'Puppy' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0). (2) The project 'Puppy' may be using a version of Gradle that does not contain the method. (3) The build file may be missing a Gradle plugin. Commented Sep 27, 2020 at 9:56

1 Answer 1

1

Solution 1: add this to your build.gradle(Module:App) dependencies,

implementation 'com.android.support:design:28.0.0-alpha3'.

Also Make sure that all Android Support dependencies have the same version like below:

dependencies {
   implementation fileTree(dir: 'libs', include: ['*.jar'])
   implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
   implementation "com.android.support:cardview-v7:28.0.0-alpha3"
   implementation 'com.android.support:recyclerview-v7:28.0.0-alpha3'
   implementation 'com.android.support:design:28.0.0-alpha3'

}

Solution 2:

Did you convert your dependencies to androidx? In Menu, press Refector and select Migrate to AndroidX, press sync gradle and it should solve this issue. and use implementation 'com.google.android.material:material:1.0.0' instead of implementation 'com.android.support:design:28.0.0-alpha3'

Sign up to request clarification or add additional context in comments.

4 Comments

Hi, thanks for your support. When I added 'com.android.support:design:28.0.0-alpha3'. I got next issue, I think because I am using androidX. Version 28 (intended for Android Pie and below) is the last version of the legacy support library, so we recommend that you migrate to AndroidX libraries when using Android Q and moving forward. The IDE can help with this: Refactor > Migrate to AndroidX... So I replaced my 'com.google.android.material:material:1.1.0-alpha08' on yours 'com.google.android.material:material:1.0.0'. It did not help.
so If you have user om.google.android.material:material:1.1.0-alpha08 then instead of android.support.design.widget.TabLayout, you need to use com.google.android.material.tabs.TabLayout
Asad khan, thanks, It is works.My mistake was that I used in gradle Module - both two libraries: 'com.google.android.material:material:1.1.0-alpha08' and 'com.android.support:design'. Additionally in XSML file I used <android.support.design.widget.TabLayout/>, I didn't know that it is not a androidx. So I removed 'com.android.support:design' from the gradle, then 'android.support.design.widget.TabLayout' I changed to "com.google.android.material.tabs.TabLayout", then in JAVA file 'import android.support.design.widget.TabLayout' I changed to 'import com.google.android.material.tabs.TabLayout'.
Happy coding :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.