android - 无法解析 API 文件 "frameworks/base/api/current.txt"

标签 android android-source android-framework android-make

我尝试在 Android 框架中添加一些文件。一切顺利,除了在编译结束时出现以下错误。

我也试过 make update-api,但运气不好,每次编译都会出现以下错误。如果有人知道如何克服这个问题,请告诉我。

Docs droiddoc: out/target/common/docs/doc-comment-check
Checking API: checkapi-last
Checking API: checkapi-current
host layoutlib_create: out/host/common/obj/JAVA_LIBRARIES/temp_layoutlib_intermediates/javalib.jar
Couldn't parse API file "frameworks/base/api/current.txt"
  ...as text: com.google.doclava.apicheck.ApiParseException: missing class or interface. got: private line 6342
  ...as XML:  com.google.doclava.apicheck.ApiParseException: Error parsing API
Couldn't parse API file "out/target/common/obj/PACKAGING/public_api.txt"
  ...as text: com.google.doclava.apicheck.ApiParseException: missing class or interface. got: private line 6342
  ...as XML:  com.google.doclava.apicheck.ApiParseException: Error parsing API
Exception in thread "main" java.lang.NullPointerException
    at com.google.doclava.apicheck.ApiCheck.checkApi(ApiCheck.java:118)
    at com.google.doclava.apicheck.ApiCheck.main(ApiCheck.java:67)

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



Couldn't parse API file "out/target/common/obj/PACKAGING/public_api.txt"
  ...as text: com.google.doclava.apicheck.ApiParseException: missing class or interface. got: private line 6342
  ...as XML:  com.google.doclava.apicheck.ApiParseException: Error parsing API
Exception in thread "main" java.lang.NullPointerException
    at com.google.doclava.apicheck.ApiInfo.isConsistent(ApiInfo.java:60)
    at com.google.doclava.apicheck.ApiCheck.checkApi(ApiCheck.java:118)
    at com.google.doclava.apicheck.ApiCheck.main(ApiCheck.java:67)

******************************
You have tried to change the API from what has been previously released in
an SDK.  Please fix the errors listed above.
******************************


make: *** [out/target/common/obj/PACKAGING/checkapi-last-timestamp] Error 38
make: *** Waiting for unfinished jobs....
make: *** [out/target/common/obj/PACKAGING/checkapi-current-timestamp] Error 38
-rw-r--r-- 1 aankit admin 9763299 Jan 31 14:21 out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar
Output: out/host/common/obj/JAVA_LIBRARIES/temp_layoutlib_intermediates/javalib.jar
Input :      out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes.jar
Input :      out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar
Found 7983 classes in input JARs.
Found 2260 classes to keep, 2143 class dependencies.
# deps classes: 2143
# keep classes: 2260
# renamed     : 19
Created JAR file out/host/common/obj/JAVA_LIBRARIES/temp_layoutlib_intermediates/javalib.jar

最佳答案

这个问题的原因是,

原因:- 我在 Android 框架中添加私有(private)类,这些类文档/声明必须添加到 “frameworks/base/api/current.txt”

解决方案:- 根据错误日志,有两种解决方案。

1) 在每个新添加的文件及其成员的每个方法的签名中添加@hide注解。

2) 使用命令 $ make update-api 然后使用 $ make -j4 或者使用 $make update-api && make -j4 ,代码现在应该可以编译了。

关于android - 无法解析 API 文件 "frameworks/base/api/current.txt",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14622020/

相关文章:

android - 默认警报对话框按钮的高度和宽度

android - 如何在 Listview 中获取上下文菜单以在 android 中删除和显示记录?

android - 带有 Google 游戏服务的多人游戏变体

android - Google+ 登录无法正常工作

android - 系统设置下缺少蓝牙

android - 使用 `onRetainCustomNonConfigurationInstance` 跨配置更改保留数据

android - 如何在 PreferenceFragment 中显示分隔符?

android - Android 中的默认动画在哪里?

android - 如何增加system.img分区大小

java - 如何在android中创建framework.odex