今天在處理一個 Android sample code 的時候,突然愈到了一些問題,解完了之後,深深覺得,這樣的系統性問題,應該更加用心去了解
遇到的問題
1. @override 會出現 error
2. 就算把 @override 都拿掉,還是會出現其他莫名奇妙的 error
這兩個 error,實際上是Eclipse 選到了 JDK5 的語法
可是 ***
絕對不是我們安裝來的 JDK 是 JDK5,我們可能已經裝過 JDK6/JDK7 了,那到底是怎樣呢?
a. 如果你的 javac -version 顯示的是 1.5.xx,麻煩請到 sun oracle 的網站上抓 jdk6 / jdk7
b. 如果你已經裝過 jdk6/idk7,那就到 project -> properties -> Java Compiler -> Compiler Compliance Level,調到 1.6 以上,這樣就可以去掉 1,2 的 error 了
3. 突然間,R 有找不到了有找不到了
R 就是 android resource 自動產生的 class,所以 R 找不到,試試看以下的步驟
a. clean project
--> 沒用,下一步
b. close Eclipse, delete gen / bin directories in the folder, restart Eclipse
--> 沒用,下一步
c. go into resource directory, change "All" upper case file name to lower case, change the name in code too.
--> 沒用,下一步.............
d. Look at compile console, if there is a "resource generating failed" message, check the fail item and do related work.
*example* if you have a.gif and a.png, the Java will complain : a is multiple defined.
delete one of the image and restart eclipse.
沒有留言:
張貼留言