【问题标题】:Cannot resolve symbol 'TabLayout' using API 28无法使用 API 28 解析符号“TabLayout”
【发布时间】:2018-10-31 20:45:56
【问题描述】:

我正在使用以下 gardle

{
compileSdkVersion 28
defaultConfig {
    applicationId "fitness.ayman.salah.fitness"
    minSdkVersion 22
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
      testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
  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:28.0.0-alpha1'
   implementation 'com.android.support.constraint:constraint-layout:1.1.3'
   testImplementation 'junit:junit:4.12'
   androidTestImplementation 'com.android.support.test:runner:1.0.2'
   androidTestImplementation 'com.android.support.test.espresso:espresso- 
   core:3.0.2'
  compile 'com.github.bumptech.glide:glide:4.0.0'
 }

我正在尝试使用 TabLayout,但找不到它(无法解析 TabLayout)。

有什么建议吗?

【问题讨论】:

标签: android


【解决方案1】:

您尚未在依赖项中添加设计支持库。根据你的编译和目标sdk添加这几行代码

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.0'

【讨论】:

  • 我做到了,我将我的版本更改为 27 并添加了你的代码,但我得到了错误。消息{种类 = 错误,文本 = 错误:预期的枚举,但得到(原始字符串)自动。,来源 = [D:\Android\Android Studio\gradle\caches\transforms-1\files-1.1\design-27.1.0. aar\f4b5d3a736bc356bea11f9cdeb7331cc\res\values\values.xml:270:5-275:13], original message=, tool name=Optional.of(AAPT)} 使缓存无效甚至手动删除,重启工作室清理项目重建上面同样的错误。
【解决方案2】:

我发现了问题

我从 attrs.xml 中删除了以下内容

 <attr name="fabSize">
    <enum name="normal" value="0" />
    <enum name="mini" value="1" />
  </attr>

问题消失了。我不确定这到底为什么会导致问题。但是解决了

【讨论】:

    【解决方案3】:

    我建议你使用这个实现

    implementation 'com.android.support:design:28.1.0'
    

    我的情况用那个实现解决了

    【讨论】:

      猜你喜欢
      • 2015-12-17
      • 1970-01-01
      • 2018-11-11
      • 1970-01-01
      • 1970-01-01
      • 2020-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多