[英]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.