我尝试在Android框架中添加一些文件。一切顺利,除了在编译结束时我遇到了错误。
我也尝试过make-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
答案 0 :(得分:11)
这个问题的原因是,
原因: - 我在Android框架中添加了私有类,这些类文档/声明必须添加到“frameworks/base/api/current.txt”
解决方案: - 根据错误日志,有两种解决方案。
1)在每个新添加的文件及其成员的每个@hide
中添加method's Signature
注释。
2)使用命令$ make update-api
然后$ make -j4
或使用$make update-api && make -j4
,代码应该可以编译。
答案 1 :(得分:2)
您是否尝试在更新api之前编译代码?似乎您添加的代码无法编译。
问题是无法解析新的api。
如果你检查external/doclava/src/com/google/doclava/apicheck/ApiFile.java
,你会找到可以帮助你的throw语句:
throw new ApiParseException("missing class or interface. got: " + token, tokenizer.getLine());
您似乎尝试添加到api 私有类或不允许的接口。要检查这一点,请尝试查看out/target/common/obj/PACKAGING/public_api.txt
文件行号6342.您应该找到导致错误的类或接口的名称。