简体   繁体   English

android.support.design.widget.TabLayout - 无法解析符号“设计”

[英]android.support.design.widget.TabLayout - cannot resolve symbol 'design'

I tried to import android.support.design.widget.TabLayout, but I got cannot resolve symbol 'design' error.我尝试导入 android.support.design.widget.TabLayout,但出现无法解析符号“设计”错误。 在此处输入图片说明

In the First I sought that is a problem with a implementation com.android.support:design version (in gradle Module).在第一个中,我发现这是一个实现 com.android.support:design版本(在 gradle 模块中)的问题。 But it is not.但事实并非如此。 I managed to find the cause of this error - dependencies versions (in gradle Project).我设法找到了这个错误的原因 - 依赖版本(在 gradle 项目中)。

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我的 android studio 版本是: 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' } } } 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
}

Solution 1: add this to your build.gradle(Module:App) dependencies,解决方案 1:将此添加到您的build.gradle(Module:App)依赖项中,

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

Also Make sure that all Android Support dependencies have the same version like below:还要确保所有 Android 支持依赖项具有相同的版本,如下所示:

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:解决方案2:

Did you convert your dependencies to androidx ?您是否将依赖项转换为androidx In Menu, press Refector and select Migrate to AndroidX , press sync gradle and it should solve this issue.在菜单中,按Refector并选择Migrate to AndroidX ,按sync gradle ,它应该解决这个问题。 and use implementation 'com.google.android.material:material:1.0.0' instead of implementation 'com.android.support:design:28.0.0-alpha3'并使用implementation 'com.google.android.material:material:1.0.0'而不是implementation 'com.android.support:design:28.0.0-alpha3'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误膨胀类 android.support.design.widget.TabLayout - Error inflating class android.support.design.widget.TabLayout Android支持设计库中的TabLayout中的IndexOutOfBoundsException - IndexOutOfBoundsException in TabLayout in android support design lib 更改TabLayout(android.support.design.widget)的选定选项卡指示器颜色 - change the selected tab indicator color of TabLayout(android.support.design.widget) TabLayout(Android支持设计)中的选项卡不会使内容膨胀 - Tab in TabLayout (Android Support Design) doesn't inflate content 如何使用Swipe视图实现android TabLayout设计支持libarary - How to implement android TabLayout design support libarary with Swipe views 未找到类Android支持设计小部件NavigationView - Class Not Found Android Support Design Widget NavigationView 无法解析符号“ Android”。Android.Support.V7.Widget.Toolbar _supporttoolbar; - Cannot resolve symbol “Android” Android.Support.V7.Widget.Toolbar _supporttoolbar; java.lang.ClassCastException:android.support.v7.widget.AppCompatButton无法转换为android.support.design.widget.FloatingActionButton - java.lang.ClassCastException: android.support.v7.widget.AppCompatButton cannot be cast to android.support.design.widget.FloatingActionButton java.lang.ClassCastException:android.support.design.widget.AppBarLayout无法转换为android.support.v7.widget.Toolbar - java.lang.ClassCastException: android.support.design.widget.AppBarLayout cannot be cast to android.support.v7.widget.Toolbar android.support.design.widget.TabItem无法转换为android.view.ViewGroup - android.support.design.widget.TabItem cannot be cast to android.view.ViewGroup
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM