错误无法解析符号 TabLayout 和“设计”
error can not resolve symbol TabLayout and 'design
请帮忙:导入时出错 android.support.design.widget.TabLayout
它说 "can not resolve symbol 'design'
我的build.gradle:
compileSdkVersion 26
buildToolsVersion "26.0.0"
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:26'
testCompile 'junit:junit:4.12'
}
您忘记添加设计支持库。只需在您的 gradle app
文件中添加此依赖项:
implementation 'com.android.support:design:26.0.+'
The Design package provides APIs to support adding material design components and patterns to your apps.
The Design Support library adds support for various material design components and patterns for app developers to build upon, such as navigation drawers
, floating action buttons (FAB)
, snackbars
, and TabLayout
.
或AndroidX依赖:
implementation "com.google.android.material:material:1.0.0"
更新:
使用 Androidx 和 Material Components library 使用:
implementation 'com.google.android.material:material:1.0.0'
OLD(支持库):[=31=]
正如您可以在 doc if you want to use the TabLayout
中检查的那样,您必须添加此依赖项:
com.android.support:design:26.0.2
在 dependencies
块中添加您的 build.gradle
:
compile 'com.android.support:design:26.0.2'
我在迁移到 androidx 时发生了这种情况。您必须将此添加到您的 gradle 文件中:
implementation 'com.google.android.material:material:1.1.0-alpha09'
此外,TabLayout 的位置也发生了变化。来自
android.support.design.widget.TabLayout
到
com.google.android.material.tabs.TabLayout
这里是 androidx 的 class mappings。
这是新的 documentation for the TabLayout。
替换为:
android.support.design.widget.TabLayout
有了这个:
import com.google.android.material.tabs.TabLayout;
为我工作! ;-)
您需要添加到build_gradle(APP):
implementation 'com.google.android.material:material:1.0.0'
请帮忙:导入时出错 android.support.design.widget.TabLayout
它说 "can not resolve symbol 'design'
我的build.gradle:
compileSdkVersion 26
buildToolsVersion "26.0.0"
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:26'
testCompile 'junit:junit:4.12'
}
您忘记添加设计支持库。只需在您的 gradle app
文件中添加此依赖项:
implementation 'com.android.support:design:26.0.+'
The Design package provides APIs to support adding material design components and patterns to your apps.
The Design Support library adds support for various material design components and patterns for app developers to build upon, such as
navigation drawers
,floating action buttons (FAB)
,snackbars
, andTabLayout
.
或AndroidX依赖:
implementation "com.google.android.material:material:1.0.0"
更新:
使用 Androidx 和 Material Components library 使用:
implementation 'com.google.android.material:material:1.0.0'
OLD(支持库):[=31=]
正如您可以在 doc if you want to use the TabLayout
中检查的那样,您必须添加此依赖项:
com.android.support:design:26.0.2
在 dependencies
块中添加您的 build.gradle
:
compile 'com.android.support:design:26.0.2'
我在迁移到 androidx 时发生了这种情况。您必须将此添加到您的 gradle 文件中:
implementation 'com.google.android.material:material:1.1.0-alpha09'
此外,TabLayout 的位置也发生了变化。来自
android.support.design.widget.TabLayout
到
com.google.android.material.tabs.TabLayout
这里是 androidx 的 class mappings。 这是新的 documentation for the TabLayout。
替换为:
android.support.design.widget.TabLayout
有了这个:
import com.google.android.material.tabs.TabLayout;
为我工作! ;-)
您需要添加到build_gradle(APP):
implementation 'com.google.android.material:material:1.0.0'