添加ActionBarSherlock库创建涉及android.support.v4错误 [英] Adding ActionBarSherlock library creates errors involving android.support.v4

查看:195
本文介绍了添加ActionBarSherlock库创建涉及android.support.v4错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现有的项目运行平稳使用片段和FragmentPagerAdapters。然而,当添加出现在 ActionBarSherlock 库错误。我发现[换个问题]有同样的问题,但目前还没有答案。

My existing project runs smoothly using Fragments and FragmentPagerAdapters. However, when adding the ActionBarSherlock library errors appear. I have found [another question] with the same problems, but there are no answers.

添加库我的项目之前,它看起来像这样没有任何错误:

Before adding the library to my project, it looks like this with no errors:

添加库后,我请编辑的Andr​​oidManifest.xml 包括安卓主题=@安卓风格/ Theme.Sherlock,这在我的XML文件中产生错误也是如此。当我将其更改为安卓主题=@风格/ Theme.Sherlock,XML文件中的错误消失,但它仍然无法正常工作,并且错误的样子这样的:

After adding the library, I edit the AndroidManifest.xml to include android:theme="@android:style/Theme.Sherlock", which produces an error in my XML file as well. When I change it to android:theme="@style/Theme.Sherlock", the error in the XML file disappears but it still doesn't work and the errors look like this:

编辑:

我所做的一切是在下面CommonsWare的回答暗示,但我的code仍不能正常工作。所有错误走开,生成项目,甚至推出我的设备上。然而,当我进入我的XML文件中的图形布局,我得到了以下错误:

I have done what was suggested in CommonsWare's answer below, but my code is still not working properly. All errors go away and the project builds and even launches on my device. However when I enter the Graphical layout of my XML files I get the following error:

The following classes could not be found:
- android.support.v4.view.PagerTabStrip (Fix Build Path, Edit XML, Create Class)

这是什么XML文件的样子。请注意,我的XML文件显示没有错误,但是当我进入图形布局选项卡出现在上面的消息。我没有提到,我使用的是 ViewPager ,但我不认为它会有所作为。

This is what the XML file looks like. Note that my XML file shows no errors, but when I enter the Graphical Layout tab the above message appears. I had not mentioned that I am using a ViewPager but I didn't think it would make a difference.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:id="@+id/wavesMonitorMenuBar"
        style="@android:style/ButtonBar"
        android:layout_alignParentBottom="true"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

    <Button
        android:id="@+id/backButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/menu_back" />

    <Button
        android:id="@+id/readButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/menu_read" />
</LinearLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/statusPager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"
    android:layout_above="@id/wavesMonitorMenuBar" >
    <android.support.v4.view.PagerTabStrip
        android:id="@+id/pager_title_strip"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:background="#9E9E9E"
        android:textColor="#fff"
        android:paddingTop="4dp"
        android:paddingBottom="4dp" />


    </android.support.v4.view.ViewPager>


</RelativeLayout>

在这里,我去选修正构建路径但还是没能解决这个问题。我试图同时选择 library.jar Android的支持 - v4.jar ,但无济于事。当我尝试打开使用XML文件,这些错误的任何意见程序崩溃。

From here I went to chose Fix Build Path but still couldn't solve the problem. I tried selecting both library.jar and android-support-v4.jar but to no avail. The program crashes when I try to open any views that use the XML files with these errors.

这是窗口,我得到当我选择修正构建路径

This is the window I get when I choose Fix Build Path:

推荐答案

由于您的控制台告诉你红,你有两个罐子,名为 Android的支持 - v4.jar ,并且它们是不一样的实际的文件 - 其大小或内容不同。因此,Android不知道你想要哪两个JAR的。

As your console is telling you in red, you have two JARs, named android-support-v4.jar, and they are not the same actual file -- their sizes or contents differ. Hence, Android does not know which of the two JARs you want.

通常情况下,简单的答案是从你的项目中删除的JAR。 ActionBarSherlock有这个​​JAR和您的项目将挑选一起来为具有ActionBarSherlock附加为库项目的一部分。

Usually, the simple answer is to delete the JAR from your project. ActionBarSherlock has this JAR, and your project will pick that one up as part of having ActionBarSherlock attached as a library project.

这篇关于添加ActionBarSherlock库创建涉及android.support.v4错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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