【问题标题】:Resource not found : Theme.Leanback找不到资源:Theme.Leanback
【发布时间】:2015-05-03 02:50:13
【问题描述】:

我正在为电视构建 android 应用程序,并将主题设置为 Theme.Leanback 在 android-support-v17-leanback.jar 支持库中定义。 但是当我构建我的应用程序时出现错误说 "错误:找不到与给定名称匹配的资源(在 'theme' 处,值为 '@style/ Theme.Leanback')"
我添加了 android-support-v17-leanback 库来构建路径,但我仍然遇到同样的错误。

甚至通过导入 Eclipse 构建了 android-support-v17-leanback 库,我在项目的 R.txt 文件中看到了资源 ID,并且我已将此构建的项目添加到我的应用程序中,但仍然出现同样的错误.

我错过了什么??请提出一些解决上述问题的想法。

谢谢, 旁白

【问题讨论】:

  • 您能分享一下您当前的配置吗?例如,Eclipse 项目设置的屏幕截图(尤其是包含库的部分),一些代码..

标签: android android-support-library android-theme television android-tv


【解决方案1】:

在 build.gradle 的依赖项部分添加 appcompat-v7 和 leanback

compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:leanback-v17:23.1.1'

在 style.xml 中

<style name="AppTheme" parent="@style/Theme.Leanback">

参考:https://developer.android.com/tools/support-library/features.html#v17-leanback

在 AndroidManifest.xml 下的 main Activity(Launcher)

<intent-filter>               

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LEANBACK_LAUNCHER" />

</intent-filter>

示例 build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.COMPANYNAME.something"
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:leanback-v17:23.1.1'
    compile 'com.android.support:design:23.1.1'
}

【讨论】:

    【解决方案2】:

    我在使用 Android Studio 时遇到了同样的问题。它在“文件”>“无效缓存/重新启动”之后神奇地开始工作。

    【讨论】:

    • 它对我不起作用..我正在使用 Andriod Studio 2 Preview 7
    • 在 Android Studio 2 Preview 9 上相同
    【解决方案3】:

    仅供参考,如果您需要可用版本号列表,可以在此处获取:

    Google Support Library Revisions

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-28
      • 2013-01-03
      • 2014-03-20
      • 2015-04-13
      • 2021-07-06
      • 1970-01-01
      • 2019-04-20
      • 2014-07-26
      相关资源
      最近更新 更多