这几天在usb上添加功能,修改了framework里面的一些源码,单独编译是没有问题的,但是在全编译的时候就遇到报错了,错误提示如下:
out/target/common/obj/PACKAGING/public_api.txt:14117: error 5: Added public field android.hardware.usb.UsbManager.USB_FUNCTION_DIAG
******************************
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.
******************************
遇到问题后还以为是代码有问题,结果找了很久,才发现跟代码没有关系,最后发现了原因,google对于所有的类和API,分为开放式和不开放式两种。所谓的开放式就是值javadoc所包含的,并不是Java中有public和private,而是跟javadoc有关系,代码没有关系。
通过查阅错误信息,有2个方法可以解决该问题:
1、将新增加的变量或方法加上"@hide" 的注释,注意一点,加"@hide" 不是简简单单的/*@hide */就行了,标准的javadoc要这样 /** */ 而且对于 format 变量 应该加上 { },也就是/**{@hide}*/
2、如果想在生成的doc中增加该变量或方法的话,必须输入:
make update-api
这样的话,系统自动将新增加的API添加到current.xml中了。