【问题标题】:What wrong with my Style? cannot resolve symbol Theme.AppCompat.Light.NoActionBar我的风格有什么问题?无法解析符号 Theme.AppCompat.Light.NoActionBar
【发布时间】:2016-11-23 06:58:17
【问题描述】:

目前,我的 styles.xml 文件显示不正确。 Theme.AppCompat.Light.NoActionBar 无法解析。我已经重新启动了android studio,但它仍然无法正常工作。我尝试了使缓存无效/重新启动,但它不起作用。它不会使我的应用程序崩溃,而是为什么会发生。看下图:

这是我的 build.gradle 文件

import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "xx.com.xxx.xxxx"
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 21
        versionName "1.2.0"
        renderscriptTargetApi 23
        renderscriptSupportModeEnabled true

        // Enabling multidex support.
        multiDexEnabled true
    }

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile('com.afollestad.material-dialogs:core:0.8.5.1@aar') {
        transitive = true
    }
    compile('com.mikepenz:actionitembadge:3.0.2@aar') {
        transitive = true
    }
    compile project(':blurringview')
    compile 'com.android.support:support-v4:23.3.0'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:design:23.3.0'
    compile 'com.android.support:cardview-v7:23.3.0'
    compile 'com.android.support:recyclerview-v7:23.3.0'
    compile 'com.google.android.gms:play-services-gcm:8.3.0'
    compile 'com.android.support:palette-v7:23.3.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.wdullaer:materialdatetimepicker:1.5.1'
    compile 'com.pnikosis:materialish-progress:1.5'
    compile 'com.mikepenz:iconics:1.3.0@aar'
    compile 'com.mikepenz.iconics:community-material-typeface:+@aar'
    compile 'com.soundcloud.android:android-crop:1.0.0@aar'
    compile 'org.apache.commons:commons-lang3:3.4'
     ...
}

...
}

【问题讨论】:

  • 你能在这里显示你的 build.gradle 文件吗?
  • 我假设您忘记在 build.gradle 中添加:compile 'com.android.support:appcompat-v7:XX.XX.XX'。观看此版本信息:developer.android.com/topic/libraries/support-library/…
  • 没有@David。我有它。在我的 build.gradle 文件中是 compile 'com.android.support:appcompat-v7:23.3.0'
  • 好的,很抱歉错误指向...您是否已经尝试清理您的项目?请出示您的 build.gradle 文件

标签: android android-studio android-appcompat android-styles


【解决方案1】:

最后,这是我的第一个解决方案。发生错误是因为 gradle 不适用于具有较低版本的库。它不会编译外部库appcompat-v7:23.3.0。我现在要做的是将 gradle 插件从 2.+ 降级到 2.2.0 和 rebuild 项目。现在又可以使用了。

此链接显示如何降级版本 gradle [Link]

这不是一个好主意,但它确实解决了我的问题。

任何其他需要改进的想法或方法,欢迎。

【讨论】:

  • 谢谢,这有助于解决我的问题。基本上,当 Android Studio 试图强制您升级它时,您永远不应该接受 gradle 升级,并且您会遇到少量错误的谷歌问题。可惜他们在编程方面如此糟糕,并且不再测试任何东西。我从来没有真正进行过 gradle 升级,不会引入错误
  • 在用 3.1.2 升级 gradle 后,我也遇到了同样的问题,按照建议重新导入后,它工作正常。你拯救了我的一天。
【解决方案2】:
  1. 退出 Android 工作室。
  2. 转到您的项目目录。
  3. 在我的情况下是这样的(F -> Android -> YourProjectName -> .idea)。
  4. 删除 .idea 文件夹中的库文件夹。
  5. 重新启动您的 Android Studio,您的问题就解决了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-27
    • 2016-10-18
    • 2018-09-20
    • 2015-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多