android - 在库项目中导入 android-support-v7-appcompat 导致 : R cannot be resolved to a variable

标签 android eclipse android-appcompat

我有一个 Android 项目,我想在其中生成两个版本,一个付费版本和一个带广告的版本。根据 Stackoverflow 上的阅读,一种方法是创建一个父项目并创建 2 个将父项目作为库导入的子项目。另外我用的是appcompat,所以层次结构如下:

enter image description here

问题是R类由于错误而没有编译,我找不到。但是当父项目没有配置为库时(“是否未选中库”)一切正常。这里的图片:

appcompat project in eclipse

appcompat build path

parent project as library and import appcompat and other libs

errors

more errors

希望你能帮助我,在此先感谢。

编辑:mark 的回答解决了 android.support.v7.appcompat.R.id.search_src_text 的问题,但我仍然有 R 类的错误,示例:

enter image description here

enter image description here

最佳答案

对不起我的英语。

将错误行替换为:

EditText editText = (EditText) searchView.findViewById(R.id.search_src_text);

关于android - 在库项目中导入 android-support-v7-appcompat 导致 : R cannot be resolved to a variable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25107688/

相关文章:

android - onPrepareOptionsMenu 安卓应用

java - Android 联系电话、地址和姓名 Intent

Android statusBarColor 与 colorPrimaryDark

android - 如何将操作栏添加到滑动 View ?

java - eclipse中的内存不足错误。为什么?

android - 我可以使用 Visual Studio 作为 IDE 进行 cocos2d-x 3.0rc2、c++ 开发吗?

java - 如何在已导入 Spring Web 项目的非 Web 项目中运行测试用例?

android - AppCompat 和 Fragment 不起作用

android - java.lang.IllegalStateException : You need to use a Theme. AppCompat 主题 - 使用 AppCompat 主题时

android - 在Android中画一条线而不将其设置为内容