0

我从这里下载了 android 演示新闻阅读器项目,并使用 Import > Existing Projects Into Workspace 将其导入到 eclipse 中。我还将 android-support-v4.jar 添加到构建路径中,就像这里所说的那样

我遇到的问题与访问资源有关。这是我得到的错误。

Description Resource    Path    Location    Type
ReaderTutorial/src/com/example/android/newsreader   line 143    Java Problem
android.app.ActionBar cannot be resolved to a variable  NewsReaderActivity.java     /NewsReaderTutorial/src/com/example/android/newsreader  line 151    Java Problem
error: Error retrieving parent for item: No resource found that matches the given name 'android:style/Widget.Holo.Light.ActionBar.TabView'. style.xml   /NewsReaderTutorial/res/values-v11  line 23 Android AAPT Problem
error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light.NoActionBar'.  style.xml   /NewsReaderTutorial/res/values-v11  line 33 Android AAPT Problem
error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light'.  style.xml   /NewsReaderTutorial/res/values-v11  line 28 Android AAPT Problem
error: Error: No resource found that matches the given name: attr 'android:actionBarTabStyle'.  style.xml   /NewsReaderTutorial/res/values-v11  line 30 Android AAPT Problem
error: Error: No resource found that matches the given name: attr 'android:actionBarTabTextStyle'.  style.xml   /NewsReaderTutorial/res/values-v11  line 29 Android AAPT Problem
FragmentTransaction cannot be resolved to a type    CompatActionBarNavHandler.java  /NewsReaderTutorial/src/com/example/android/newsreader  line 54 Java Problem
FragmentTransaction cannot be resolved to a type    CompatActionBarNavHandler.java  /NewsReaderTutorial/src/com/example/android/newsreader  line 76 Java Problem
FragmentTransaction cannot be resolved to a type    CompatActionBarNavHandler.java  /NewsReaderTutorial/src/com/example/android/newsreader  line 84 Java Problem
OnNavigationListener cannot be resolved to a type   CompatActionBarNavHandler.java  /NewsReaderTutorial/src/com/example/android/newsreader  line 35 Java Problem
R cannot be resolved to a variable  ArticleActivity.java    /NewsReaderTutorial/src/com/example/android/newsreader  line 51 Java Problem
R cannot be resolved to a variable  HeadlinesFragment.java  /NewsReaderTutorial/src/com/example/android/newsreader  line 75 Java Problem
R cannot be resolved to a variable  NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader  line 76 Java Problem
R cannot be resolved to a variable  NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader  line 80 Java Problem
R cannot be resolved to a variable  NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader  line 82 Java Problem
R cannot be resolved to a variable  NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader  line 86 Java Problem
R cannot be resolved to a variable  NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader  line 101    Java Problem
R cannot be resolved to a variable  NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader  line 152    Java Problem
R cannot be resolved to a variable  NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader  line 183    Java Problem
Tab cannot be resolved to a type    CompatActionBarNavHandler.java  /NewsReaderTutorial/src/com/example/android/newsreader  line 54 Java Problem
Tab cannot be resolved to a type    CompatActionBarNavHandler.java  /NewsReaderTutorial/src/com/example/android/newsreader  line 76 Java Problem
Tab cannot be resolved to a type    CompatActionBarNavHandler.java  /NewsReaderTutorial/src/com/example/android/newsreader  line 84 Java Problem
TabListener cannot be resolved to a type    CompatActionBarNavHandler.java  /NewsReaderTutorial/src/com/example/android/newsreader  line 35 Java Problem
The import android.app.ActionBar cannot be resolved CompatActionBarNavHandler.java  /NewsReaderTutorial/src/com/example/android/newsreader  line 19 Java Problem
The import android.app.ActionBar cannot be resolved CompatActionBarNavHandler.java  /NewsReaderTutorial/src/com/example/android/newsreader  line 20 Java Problem
The import android.app.ActionBar cannot be resolved CompatActionBarNavHandler.java  /NewsReaderTutorial/src/com/example/android/newsreader  line 21 Java Problem
The import android.app.FragmentTransaction cannot be resolved   CompatActionBarNavHandler.java  /NewsReaderTutorial/src/com/example/android/newsreader  line 22 Java Problem
The method getActionBar() is undefined for the type NewsReaderActivity  NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader  line 137    Java Problem
The method onNavigationItemSelected(int, long) of type CompatActionBarNavHandler must override or implement a supertype method  CompatActionBarNavHandler.java  /NewsReaderTutorial/src/com/example/android/newsreader  line 65 Java Problem

我知道这没什么可做的,但是我一直在四处寻找,但找不到任何东西,因为它是一个全新的演示。

我认为可能是没有生成 R.java 文件,因为我在我的 gen 目录中找不到它。我曾尝试清理项目并重新启动 Eclipse,但它们没有工作。

任何帮助都会很重要。

迪斯科

4

3 回答 3

5

已经有一段时间了,但这为我解决了问题。
您是否导入:

import android.app.ActionBar;

出于某种原因,我的项目有:

import android.app.ActionBar.Tab;
import android.app.ActionBar.TabListener;

import android.app.ActionBar;它奏效了。

于 2013-02-15T21:37:19.933 回答
0

您需要将构建目标更改为 API 级别 11 或更高。

于 2012-07-06T05:29:55.753 回答
0

您需要点击 Android Manifest.xml 文件下的项目属性文件,并将目标从 8 更改为您的目标 13 或以上。

于 2013-07-24T17:32:32.340 回答