2016-05-26 51 views
0
Theme.AppCompat.Light.NoActionBar 

显示为红色且未被识别。这是我做了什么:使用SDK经理如何使用Intellij导入appcompat-v7

下载支持库

推门进去,项目结构中添加一个新的图书馆,选择的程序兼容性-v7-23.4.0-javadoc.jar和程序兼容性,v7- appcompat-7的23.4.0文件夹中的23.4.0-sources.jar文件。

选择OK后,将appcompat-v7-23.4.0-sources添加到我的库中。

然后我去了Modules - > Dependencies以确保appcompat-v7-23.4.0-sources被选中并点击OK。

它没有工作......?该行仍然无法识别,图书馆甚至没有出现在我的libs文件夹中。我尝试了另一种方式来复制.jar文件,将它们粘贴到我的libs文件夹中,然后右键单击以从此处添加到库,但同样的事情发生。我怎样才能使这个工作?我的分钟设置为7,目标21和清单中最多23个。 styles.xml中的错误是“无法解析符号”。

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <style name="AppTheme" parent="AppTheme.Base"></style> 
    <!-- Base theme applied no matter what API --> 
    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar"> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
    </style> 
</resources> 

我试图重建我的项目,只有这样,我得到了以下错误:

Information:5/26/16, 12:29 PM - Compilation completed with 4 errors and 0 warnings in 4s 99ms 
/Users/accudeveloper/Android-App-2.0/android2.0/res/values/styles.xml 
Error:(5, -1) android-apt-compiler: [android2.0] /Users/accudeveloper/Android-App-2.0/android2.0/res/values/styles.xml:5: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'. 
Error:(8, -1) android-apt-compiler: [android2.0] /Users/accudeveloper/Android-App-2.0/android2.0/res/values/styles.xml:8: error: Error: No resource found that matches the given name: attr 'colorAccent'. 
Error:(6, -1) android-apt-compiler: [android2.0] /Users/accudeveloper/Android-App-2.0/android2.0/res/values/styles.xml:6: error: Error: No resource found that matches the given name: attr 'colorPrimary'. 
Error:(7, -1) android-apt-compiler: [android2.0] /Users/accudeveloper/Android-App-2.0/android2.0/res/values/styles.xml:7: error: Error: No resource found that matches the given name: attr 'colorPrimaryDark'. 

这是我找到的.jar文件。这条道路看起来是否正确?基于此网站上的相关问题的答案

Android的SDK /演员/安卓/ m2repository/COM /安卓/支持/程序兼容性-V7

应该有一个程序兼容性/ RES /值目录以及但我没有看到。

+0

为什么不使用FREE-ANDROID STUDIO,这是在GOOGLE支持下的类固醇上的intelliJ-Idea? –

+0

我遵循的一些教程使用了IntelliJ,所以我就坚持使用它。但所有这些都让我头痛。我最终可能会试用Android Studio。 – terratunaz

+0

再次,Android Studio使用相同的内核,相同的快捷方式,相同的界面。并且无需卸载IDEA,您可以安装少量Android Studios实例。 –

回答

1

尝试编译这个依赖于你的build.gradle

dependencies 
    { 
     compile 'com.android.support:appcompat-v7:23.2.1' 
    } 

和同步尝试后清洁你的项目

+0

我没有在我的项目中只有build.xml文件。 – terratunaz

+0

然后您需要将库jar文件复制到libs文件夹,并将其添加到您的项目 – Max

+0

谢谢,但我已经尝试过,它仍然无法正常工作。 – terratunaz

1

编译您的摇篮。除了android avd之外的绿色(看起来像地图标记)或尝试重建您的项目。

如果仍然存在,请删除它们。重建您的项目并粘贴下面的gradle。

编译 'com.android.support.appcompat-V7:23.4.0'

你可以在这里找到它。

enter image description here

对不起,质量差的图像。

尝试删除App主题的样式。在你的Theme.AppCompat上方并且 正如我所看到的你的风格名称=“AppTheme.Base” - 删除.Base

结果会是这样的。 enter image description here

+0

您还可以使用打印屏幕(PrtSc)获取屏幕快照 – Isaac

+0

我正在使用手机,手机数据。我会尝试 – RoCk

+0

谢谢你的图像,但我试图重建项目,并得到以下错误: 错误:(5,-1)android-apt-compiler:[android2.0]/Users/accudeveloper/Android- App-2.0/android2.0/res/values/styles.xml:5:错误:检索父项的错误:找不到与给定名称'Theme.AppCompat.Light.NoActionBar'匹配的资源。 当我开始这个项目时,我只选择了Android,并没有使用Gradle:Android模块。 – terratunaz

0

我最终捣毁了整个项目,并创建一个新的,这个时候开始的Android应用程序,并确保摇篮被列入沿着它和所有我需要已经包含的依赖关系立即工作过我的代码。这种方式更容易。不知道我之前做了什么(我不认为我甚至从Android SDK抓取了正确的文件夹,因为我实际上需要的文件夹显然已经过时 - Android支持库),但我现在将使用Gradle for我的项目。感谢所有尝试提供帮助的人。