找不到资源:Theme.Leanback

Nar*_*tor 5 android television android-theme android-support-library android-tv

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

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

我错过了什么?请提出一些解决上述问题的建议.

谢谢,讲述者

Sad*_*diq 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'
Run Code Online (Sandbox Code Playgroud)

在style.xml中

<style name="AppTheme" parent="@style/Theme.Leanback">
Run Code Online (Sandbox Code Playgroud)

参考: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>
Run Code Online (Sandbox Code Playgroud)

示例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'
}
Run Code Online (Sandbox Code Playgroud)