java.lang.NoSuchFieldError: android.support.v7.appcompat.R$styleable.Theme_w的解決辦法

這幾天在搞Fragment和ViewPager的整合,實現底部導航欄的效果,用到了AppCompatActivity,AppCompatActivity是在support library 22之後纔有的。我的一開始是19的版本,後面去網上下了個22的support library導進去之後就可以編譯通過了,但是運行卻報了java.lang.NoSuchFieldError: android.support.v7.appcompat.R$styleable.Theme_w。想了很久。

我猜原因是:因爲我建的Android項目最少支持是3.0的,所以會有一個appcompat_v7的項目關聯到一起了,而在關聯的項目裏面的android.support.v7.appcompat包下的R.java文件是找不到styleable.Theme_w的,所以報了以上錯誤。後來我就把Android sdk manager裏面的support library 更新爲22.但是更新爲22之後又遇到了新建項目時報了No resource found that matches the given name xxxx之類的錯誤。去網上搜了下,是因爲Android sdk build-tools和sdk platform的版本太低了導致的。最後我把它們的版本到升級到22就可以解決了。

所以綜上所述。報這個錯誤很有可能是你的sdk 版本太低了,升級之後就可以解決這個問題了。


No resource found that matches the given name

No resource found that matches the given name

No resource found that matches the given name

No resource found that matches the given name

No resource found that matches the given name

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章