3

所以我遇到了很大的问题,我需要尽快修复它。我做了我的comp格式并安装了新版本的eclipse。我导入了我的项目以及它使用的 2 个库。这两个库被命名为 v7/gridlayout 和 actionbarsherlock/library。在 android 和参考下,它表明我包含了这 2 个库。他们看起来编译得很好。但是当我清理我的项目时,我得到一个错误:

The type com.google.android.maps.MapActivity cannot be resolved. It is indirectly referenced from required .class files

在线:

public class MainActivity extends SherlockMapActivity implements ActionBar.TabListener 

好的,由于某种原因,我的应用程序现在需要构建为 google api。所以我这样做。现在我的 R 文件没有被创建,我得到这个错误:

R cannot be resolved to a variable

我认为这可能意味着我的布局有一些错误,但在哪里?当我检查它们时,我发现它们都有相同的错误:

Missing styles. Is the correct theme chosen for this layout?
Use the Theme combo box above the layout to choose a different layout, or fix the theme style references.

所以我又回到了夏洛克有问题的问题......

有任何想法吗?

顺便说一句:在 .xml 我用这个作为主题:

xmlns:android="http://schemas.android.com/apk/res/android"

我觉得问题出在这里:

  [2012-09-27 12:54:37 - com.motiviti.zmapp.MainActivity] C:\Users\mitja\Desktop \zmap\res\values-v11\styles.xml:3: error: Error retrieving parent for item: No resource   found that matches the given name 'android:Theme.Holo.Light'.
  [2012-09-27 12:54:37 - com.motiviti.zmapp.MainActivity] C:\Users\mitja\Desktop\zmap\res\values-v14\styles.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light.DarkActionBar'.
4

4 回答 4

2

您应该检查以下几点:

  1. 由于您更改了 eclipse,我想您下载了最新的 adt 插件。如果您的项目有一个libs文件夹并且您的所有库都在那里,请检查项目属性是否在 java 构建路径上有这些库的引用。如果是这种情况,请删除它们,因为最新的 adt 插件会为您执行此操作(请记住,您的文件夹名称必须是libs)。我已经遇到了这个问题,很难找到。

  2. 如果我没记错的话,Sherlock 是一个与您的项目相关联的项目库。这意味着 Sherlock 项目必须在您的工作区中并且必须打开才能编译。请参阅http://actionbarsherlock.com/usage.html

  3. ABS 用法来看:Since the library is an extension of the official support library you must also have the android-support-v4.jar referenced by your project

  4. 检查您是否使用 Android 4.0+ 进行编译,因为 Sherlock 需要:Due to its use of the native action bar and its related classes on Ice Cream Sandwich, the library requires that both it and your project are compiled with Android 4.0 or newer. The project also requires that you are compiling with JDK 1.6 in both your editor and any build systems that you may be using.

于 2012-09-27T11:22:09.777 回答
0

从您的项目属性中检查您是否选择了您正在使用的平台版本的 Google API 版本。当我设置为没有 Google API 的项目设置平台版本时,我收到了完全相同的错误消息。

于 2013-01-14T18:29:56.450 回答
0

在您的清单中确保您使用的是 ActionBarSherlock 的主题。

<application
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/Theme.Sherlock">

还添加:

<uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="16"/>

将您的构建目标设置为 Google API,API 级别 16(或至少 15,但相应地修改您的清单)。

确保您使用的是支持库。

于 2012-09-27T10:51:33.770 回答
0

就我而言,解决方案是从针对 Android 4.0 SDK 构建切换到针对 Android 4.0 的“Google API”SDK 构建。

于 2013-04-25T00:57:18.193 回答