[問題] Android source code中插code

看板java作者 (原味的死魚)時間16年前 (2009/12/01 17:36), 編輯推噓1(102)
留言3則, 2人參與, 最新討論串1/1
我要插的code是要開檔並且寫入目前執行的function名稱以及目前時間 一開始我是直接在source code(Request.java)中插開檔寫檔的程式碼 但是失敗了!!而且還造成之後打開SDK模擬器時browser功能掛掉 接下來我有找尋一些其他方法 有人用寫application的方式先寫好一支可以開檔寫檔的應用程式 只要這個應用程式work把這段程式放到原本要插的source code中也會是可以work的 所以我也寫了一個簡單的開檔、寫檔的應用程式 也的確可以順利的運作 但在把這段程式碼放到Request.java中接著對source code重新compile 反而出現了error!! 不知道是這個方法錯誤還是我有什麼誤解? 又或是其他方法才是對的? 不知道板上的高手們有什麼看法? 附上我的程式片段 File MyFile = new File("/sdcard/log.txt"); try { FileWriter MyFileWriter = new FileWriter(MyFile,true); BufferedWriter MyFileBuffer; MyFileBuffer = new BufferedWriter(MyFileWriter); MyFileBuffer.write((int) System.currentTimeMillis()+" sendRequest_start"); MyFileBuffer.newLine(); MyFileBuffer.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } compile之錯誤訊息: target Java: framework (out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes) frameworks/base/core/java/android/net/http/RequestQueue.java:330: cannot find symbol symbol : constructor Request(java.lang.String,org.apache.http.HttpHost,org.apache.http.HttpHost,java.lang.String,java.io.InputStream,int,android.net.http.EventHandler,java.util.Map<java.lang.String,java.lang.String>) location: class android.net.http.Request req = new Request(method, httpHost, mProxyHost, uri.mPath, bodyProvider, bodyLength, eventHandler, headers); ^ frameworks/base/core/java/android/net/http/Request.java:239: cannot find symbol symbol : variable MyFileBuffer location: class android.net.http.Request MyFileBuffer.write((int) System.currentTimeMillis()+" sendRequest_end"); ^ frameworks/base/core/java/android/net/http/Request.java:240: cannot find symbol symbol : variable MyFileBuffer location: class android.net.http.Request MyFileBuffer.newLine(); ^ frameworks/base/core/java/android/net/http/Request.java:241: cannot find symbol symbol : variable MyFileBuffer location: class android.net.http.Request MyFileBuffer.close(); ^ Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 4 errors make: *** [out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-full-debug.jar] Error 41 而且將原始的Request.java覆蓋回去之後 雖然最後三項error會消失但是第一個error卻仍然存在 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.114.75.116

12/02 08:46, , 1F
明天我沒看到補上失敗的情形, e.printStackTrace 結果
12/02 08:46, 1F

12/02 08:48, , 2F
等失敗情況的說明,就當違反版規五
12/02 08:48, 2F
※ 編輯: naifish 來自: 140.114.85.183 (12/02 19:35)

12/02 19:35, , 3F
抱歉誤觸版規!
12/02 19:35, 3F
文章代碼(AID): #1B5EEZVq (java)