Android 更新系統api接口須要同時提交current.txt

修改framework/base下面的api要注意更新api/current.txt文件java

更新android系統接口後,只是提交java文件會致使其餘人編譯不經過,須要提交/framework/base/api下面更新的三個問文件:android

 

若是修改了Android原有API的 ,須要update frameworks/base/api/current.txt。不然編譯被中斷並出現編譯錯誤提示。api

不然,編譯時會報如下錯誤:app

frameworks/base/services/java/com/android/server/SystemServer.java:592: cannot find symbol
symbol  : variable PPPOE_SERVICE
location: class android.content.Contextide

能夠經過運行 make update-api 後,自動更新此文件,檢查確認正確後,跟代碼一塊兒提交便可。ui

切記:不能手動更改api/current.txt文件去更新。
--------------------------------------------------------------------------------------------------------------------------------------spa

 

當咱們對framework/base/下新增aidl,也就是新增向上api的時候,編譯容易出現如下的錯誤:server

frameworks/base/api/system-current.txt:25031: error 8: Removed public class android.os.IXxxService
frameworks/base/api/system-current.txt:25036: error 8: Removed public class android.os.IXxxService.Stub
out/target/common/obj/PACKAGING/system-api.txt:25035: error 3: Added class IXxxService to package android.os
out/target/common/obj/PACKAGING/system-api.txt:25040: error 3: Added class IXxxService.Stub to package android.osblog

這是由於新增或者修改的api沒有及時同步到/frameworks/base/api/system-current.txt文件中,這個時候編譯會失敗。還有有如下的提示:接口

******************************
You have tried to change the API from what has been previously approved.

To make these errors go away, you have two choices:
   1) You can add "@hide" javadoc comments to the methods, etc. listed in the
      errors above.

   2) You can update current.txt by executing the following command:
         make update-api

      To submit the revised current.txt to the main Android repository,
      you will need approval.
******************************

這個時候咱們就須要先執行:

# make update-api

進行同步,再對代碼進行編譯即可解決上面的問題。
-------------------------------------------------------------------------------------------------------------------------------------

什麼時候須要執行make update-api命令

添加系統API或者修改@hide的API後,須要執行
make update-api,而後再make
修改公共api後,須要
make update-api

一、在修改完系統Api或部分公共Api後(常見於修改Intent.java、KeyEvent.java等等),執行源碼編譯時會有以下提示
see build/core/apicheck_msg_current.txt
******************************
You have tried to change the API from what has been previously approved.

To make these errors go away, you have two choices:
1) You can add "@hide" javadoc comments to the methods, etc. listed in the
errors above.

2) You can update current.txt by executing the following command:
make update-api

To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
二、錯誤信息代表是因爲API錯誤致使
谷歌對於全部的類和API,分爲開放和非開放兩種:而開放的類和API,能夠經過「Javadoc標籤」與源碼同步生成「程序的開發文檔」;當咱們修改或者添加一個新的API時,咱們有兩種方案能夠避免出現上述錯誤.

一是將該接口加上 非公開的標籤:/*{@hide}/;二能夠在修改後執行:make update-api(公開),將修改內容與API的doc文件更新到一致。三、解決辦法:執行: make update -api ;修改後相應API文件後,在base庫下面會產生「.current.txt」文件的差別,提交時將該差別一併提交審覈便可。

相關文章
相關標籤/搜索