Android Studio:无法找到符号变量navigation_icon_list

问题描述:

在Android Studio中出现以下错误。Android Studio:无法找到符号变量navigation_icon_list

错误:无法找到符号变量navigation_icon_list

这里是它的谈论

// icon list 
TypedArray iconTypedArray = getResources().obtainTypedArray(R.array.navigation_icon_list); 
Integer[] icons = new Integer[iconTypedArray.length()]; 
for(int i=0; i<iconTypedArray.length(); i++) 
{ 
    icons[i] = iconTypedArray.getResourceId(i, -1); 
} 
iconTypedArray.recycle(); 

我在另一计算器疑问,他通过移除import [appname].R;解决它读取。我尝试过,但没有奏效。

任何帮助,将不胜感激。

我相信这可能与我在过去两个月左右频繁进行的操作相同。我通常的解决问题的方法是从命令行运行gradle clean(不像IDE干净的方式运行所有其他命令),然后在IDE中运行构建。在某些情况下,这不起作用,我将在IDE的文件菜单中进行无效并重新启动。

另外我已经注意到,在Android插件1.4测试版中,我必须在每个构建之间运行一次清理,以便对XML进行更改才能生效。 (可能是他们放弃1.4插件并跳到1.5的原因的一部分)

是您的进口声明红色以及R.array.navigation_icon_list?您使用的是什么版本的IDE,Gradle和Android gradle插件?

+0

否导入代码不是红色。我正在使用Android Studio 1.4,Gradle 2.2.1和Android Plugins是1.3.0。 – m0nsta

+0

要验证的另一件事是XML文件包含在您的srcSets中,并且您的XML全部构建正确。 http://developer.android.com/guide/topics/resources/more-resources.html#TypedArray事实上,appname.R类存在并且缺少值表示您的arrays.XML文件未包含在合并中/进程资源任务。 – TrevJonez