今天增加了一个系统API后,编译失败了,折腾出来才知道自己出现低级错误!
一、使用场景
- 增加系统API
- 修改@hide的API
- 修改公共API
存在以上修改后,都需要先执行make update-api,然后再make
二、缘起
1. 在以上使用场景下,编译系统源码都会出现如下提示
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时,我们有两种方案可以避免出现上述错误.
方案1:将该接口加上非公开的标签:/** @hide */ ;
方案2:修改后执行:make update-api(公开),将修改内容与API的doc文件更新到一致。
---------------------------------------------------------------------------------------------------------
关于“方案1”需要注意的是,并不是简单写个@hide 或者 /@hide/ 就可以了,这些都是错误的javadoc注释格式,标准的javadoc都是这样的 /** / 而且对于 format 变量 应该加上 { }。以我们应该这样写 /* {@hide} */
错误javadoc注释格式
示例1: /* @hide */ -------写成这样,犯了低级错误
示例2: /*
*@hide
* /