Android Studio 支持库 v7 [英] Android Studio Support Library v7

查看:52
本文介绍了Android Studio 支持库 v7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用支持操作栏.我已按照有关如何在 Android Studio v 0.3.0 中包含支持库的所有说明进行操作.我的 build.gradle 的依赖项如下所示:

I am attempting to use the Support Action Bar. I have followed all the instructions on how to include the support library in Android Studio v 0.3.0. My build.gradle's dependencies look like:

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':NineOld')
    compile project(':Helpshift')
    compile project(':SlidingMenu:library')
    compile project(':AmbilWarna')
    compile 'com.android.support:support-v4:18.0.+'
    compile 'com.android.support:appcompat-v7:18.0.+'
}

当我尝试使用主题时:

android:theme="@android:style/Theme.AppCompat"

Android Studio 表示无法解析符号.我知道这曾经是一个问题,但我相信它已在 0.2.6 中修复.

Android Studio says it cannot resolve the symbol. I know this used to be an issue, but I believe it was fixed in 0.2.6.

在构建项目时,我得到

Gradle:找不到与给定名称匹配的资源(在 'theme' 处,值为 '@android:style/Theme.AppCompat').

Gradle: No resource found that matches the given name (at 'theme' with value '@android:style/Theme.AppCompat').

使用依赖项清理项目后,我应该会看到外部库中的 jar.正确的?目前,我只看到了 support-v4-18.0.0 jar.

After I clean the project with the dependencies, I should see the jars in the External Libraries. Correct? At the moment, I only see the support-v4-18.0.0 jar.

推荐答案

删除android:"前缀.

Remove the "android:" prefix.

未包含在最低 API 级别中的样式和主题将不存在.因此,如果您的最低 API 级别为 8 (Froyo),那么每当您为资源添加前缀android:"时,它都会在 androidres"文件夹中查找平台 8 (android-sdk\platforms\android-8\data\res).

Styles and Themes not included in your minimum API level will not be there. So if you're minimum API level is 8 (Froyo), then any time you prefix a resource with "android:" it's going to look in the android "res" folder for platform-8 (android-sdk\platforms\android-8\data\res).

最后,您需要使用 AppCompat 库的主要原因是Theme.Holo"不存在于您的平台res"文件夹中,除非您将最低 API 级别提高到 11 (Honeycomb).

Lastly, the main reason why you need to use the AppCompat library is because the "Theme.Holo" does not exist in your platform "res" folder unless you raise your minimum API level to 11 (Honeycomb).

这篇关于Android Studio 支持库 v7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆