Android 更新系统api接口需要同时提交current.txt

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

更新android系统接口后,只是提交java文件会导致其他人编译不通过,需要提交/framework/base/api下面更新的三个问文件:

如果修改了Android原有API的 ,需要update frameworks/base/api/current.txt。否则编译被中断并出现编译错误提示。

否则,编译时会报以下错误:

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

可以通过运行 make update-api 后,自动更新此文件,检查确认正确后,跟代码一起提交即可。

切记:不能手动更改api/current.txt文件去更新。
--------------------------------------------------------------------------------------------------------------------------------------

当我们对framework/base/下新增aidl,也就是新增向上api的时候,编译容易出现以下的错误:

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.os

这是因为新增或者修改的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

1、在修改完系统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.
******************************
2、错误信息表明是由于API错误导致
谷歌对于所有的类和API,分为开放和非开放两种:而开放的类和API,可以通过“Javadoc标签”与源码同步生成“程序的开发文档”;当我们修改或者添加一个新的API时,我们有两种方案可以避免出现上述错误.

一是将该接口加上 非公开的标签:/*{@hide}/;
二可以在修改后执行:make update-api(公开),将修改内容与API的doc文件更新到一致。
3、解决办法:
执行: make update -api ;
修改后相应API文件后,在base库下面会产生“.current.txt”文件的差异,提交时将该差异一并提交审核即可。

原文地址:https://www.cnblogs.com/yangjj08/p/11286956.html