Android中cannot be resolved or is not a field錯誤的解決辦法
以下問題可以參考:
1.R cannot be resolved or is not a field
2.id cannot be resolved or is not a field
在寫第一程式的時候,遇到了這個錯誤,我在引用一個變數時,ListView myListView = (ListView)findViewById(R.id.myListView);
總是提示我這個錯誤,但是我仔細檢查了layout檔案中我已經寫的就是這個id.
然後我試著import R,這時候R下面又提示這個錯誤了
於是我把import這一句刪除了(1.R cannot be resolved or is not a field的解決方法)
在網上大致搜尋了一下,大家給出的意見就是沒有儲存好layout沒有生成R檔案
於是我多次儲存但還是不行,
這時候我發現自己res/menu/下的檔案也有提示錯誤,開啟後發現是android:title引用了string檔案中一個我剛剛刪除的變數,
把這個引用改成輸入一個字串或者在res/values/string檔案下新增這個引用
這時候再去給layout檔案加一個空格什麼的重新儲存一下,R檔案就會生成了.
總的來說,出現問題2的原因就是R檔案沒有生成,或者更改後沒有生成好,自習檢查自己的程式碼後,再去查詢其他檔案中有沒有錯誤,所有檔案沒有錯誤,R檔案才可以自動生成
----------------分割線------------------
補充:大多時候,是資原始檔出現錯誤,有時候eclipse就不會報錯,但是你clean後,因為專案有錯誤,R檔案就消失了。
例如:drawable中的圖片檔案,不能有大寫等
相關推薦
Android中cannot be resolved or is not a field錯誤的解決辦法
以下問題可以參考: 1.R cannot be resolved or is not a field 2.id cannot be resolved or is not a field 在寫第一程式的時候,遇到了這個錯誤,我在引用一個變數時,ListView myList
Eclipse Android專案 為控制元件添加了Id,但是在Java程式碼中提示xxx cannot be resolved or is not a field
在Android開發過程中,常需要在佈局檔案中為控制元件新增Id,以便在Java程式碼中找到這個控制元件。 但在使用Eclipse進行開發的過程中,常會出現明明已經在Layout XML檔案中為元件添
報出現“"cannot be resolved or is not a field",
出現“"cannot be resolved or is not a field",是因為當前java類的匯入不是當前專案的R檔案 ,而是匯入了Android.R檔案。 解決:找到對應報錯誤的類,刪除java程式碼中的”import Android.R“(在類匯入部分)。
Androidannotation 報錯:cannot be resolved or is not a field
我今天終於解決這個問題, 專案應用了androidannotation,以註解方式編寫程式碼,很快很順暢。。。。。 寫著寫著,突然報了:cannot be resolved or is not a
Maven工程中提示:Archive for required library...cannot be read or is not a valid ZIP file
Problem Description I create maven project in Eclipse. Then I got some problems in Markers tab: Solution 1. Enter the directory mentioned in
解決使用maven的java web項目導入後出現的有關問題 -cannot be read or is not a valid ZIP file
valid 鏡像 項目 bsp 阿裏 可能 錯誤 mini java 錯誤問題:雖然查找repository目錄下是有jar包,但是jar包是有問題的(可能是下載不完整),所以更改鏡像地址到國內。 解決方案: 1)刪除提示錯誤路徑下的所有jar包(C:
解決java web專案匯入後出現的有關問題 -cannot be read or is not a valid ZIP file
解決java web專案匯入後出現的問題 —cannot be read or is not a valid ZIP file 今天匯入以前的2個web專案後會出現以下三個錯誤: 1. Archive for required library: ‘W
NodeJS | 連線mongodb資料庫成功之後報db.collection is not a function錯誤解決辦法(四)
在nodejs操作mongodb顯示資料庫連線成功之後突然報了db.collection is not a function錯誤,引起這個錯誤的原因是nodejs獲取資料庫表的API寫法不對。(正如NodeJS | 入門篇 (一)提到的,不同版本的API,使用規範有差別)。修改方式如下: var
Archive for required library: ‘WebContent/WEB-INF/lib/xxx.jar cannot be read or is not Zip file
今天匯入一個專案到eclipse,出現感嘆號,而且報1. Archive for required library: ‘WebContent/WEB-INF/lib/xxxxx.jar cannot be read or is not a valid ZI
The type javax.servlet.http.HttpServletRequest cannot be resolved. It is indirectly reference 問題之解決
問題原因: 專案中缺少jar包:servlet-api.jar 解決辦法: 方法1:把 servlet-api.jar 新增到專案中(該jar包在Tomcat目錄的lib資料夾下) 方法2:專案中新增
'AddressOf' expression cannot be converted to 'Long' because 'Long' is not a delegate type.解決辦法
編寫鉤子程式時,在程式碼: hHook = SetWindowsHookEx(WH_MOUSE_LL, AddressOf HookProc, App.hInstance, 0) 處出現錯誤,提示'AddressOf' expression cannot be conver
JS中常見的 “函式名 is not a function” 錯誤
js中常見的錯誤,例如Uncaught TypeError: x is not a function 其原因除了函式本身有錯之外,還有一種很奇怪的情況:函式本身沒有錯,但是執行時就是不能正常執行。這種情況與javascript的特性有關:變數與函式宣告前置的優先順序。 首
Android之xxx is not a concrete class解決辦法
今天給以前一個app加歡迎介面,照著網上的教程做,改manifest.xml檔案的時候給我報一個com.aaa.Welcome is not a concrete class的錯誤,百思不得其解 我
執行HBase shell時出現ERROR: org.apache.hadoop.hbase.ipc.ServerNotRunningYetException: Server is not running yet錯誤解決辦法(圖文詳解)
cep ESS 關註 align comm util code ade dap 不多說,直接上幹貨! [kfk@bigdata-pro01 bin]$ jps 1968 NameNode 2385 ResourceManager 2259 Jou
layUI表單提交時,控制檯出現$(...)serializeObject is not a function錯誤——解決方案
先上錯誤:這個錯誤是在控制檯爆出的錯誤,序列化表單,點選儲存按鈕是出現$(...)serializeObject is not a function,這個錯誤的意思是找不到serializeObjec
$.TOJSON IS NOT A FUNCTION的解決辦法
使用ajax非同步載入:setTimeout(function() { $.ajax({ type : 'post', cache : false, async : false,
The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
it is miss ati refers () imp -s tar pre 問題描述 Exception in thread "main" java.lang.Error: Unresolved compilation problems: The t
eclipse中" cannot be resolved to a type"的解決辦法
博主今天在敲程式碼的時候發現報了" cannot be resolved to a type"這個錯誤,在網上一搜才知道解決方案,現在分享給大家: (1)jdk不匹配(或不存在) 專案指定的jdk為“jdk1.6.0_18”,而當前eclipse使用的是“j
在寫反射的時候myeclipse報錯The type javax.servlet.ServletContext cannot be resolved. It is indirectly referen
public class MyReflect {public String className = null;public Class personClass= null;@Beforepublic void init() throws ClassNotFoundExcep
java 錯誤:The type java.util.Comparator cannot be resolved. It is indirectly referenced from required
The type java.util.Comparator cannot be resolved. It is indirectly referenced from required .class files 1、錯誤描述: 源專案編譯環境為jdk1.7 後來換成了jd