找不到资源:Theme.Leanback

时间:2015-03-02 16:47:05

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

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

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

我还缺什么?请提出一些解决上述问题的建议。

谢谢, 叙述者

3 个答案:

答案 0 :(得分:8)

在build.gradle

中添加appcompat-v7和leanback in dependencies部分
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

主要活动(Launcher)下的AndroidManifest.xml中的

<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'
}

答案 1 :(得分:3)

我使用Android Studio遇到了同样的问题。它神奇地开始工作&#34; File&#34; &GT; &#34;使缓存无效/重新启动&#34;。

答案 2 :(得分:0)

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

Google Support Library Revisions