Couldn't parse API file "frameworks/base/api/current.txt"

16,021

Solution 1

The reason for this issue was ,

Cause :- I was adding private classes in Android Frameworks and these classes documentation/declarations must be added to “frameworks/base/api/current.txt”

Solution :- as per error logs, There are two solutions.

1) add @hide annotation in each method's Signature in each newly added file and its members.

2) use commands $ make update-api then $ make -j4 or either use $make update-api && make -j4 , and code should be compilable now.

Solution 2

Have you tried to compile you code before updating api? It seems that the code you've added cannot be compiled. The problem is that new api cannot be parsed. If you check external/doclava/src/com/google/doclava/apicheck/ApiFile.java you'll find the the throw statement that can help you:

throw new ApiParseException("missing class or interface. got: " + token, tokenizer.getLine());

It seems that you try to add to api private class or interface that is not allowed. To check this try to look into out/target/common/obj/PACKAGING/public_api.txt file line number 6342. There you should find the name of the class or interface that causes the error.

Share:
16,021
AAnkit
Author by

AAnkit

Updated on June 25, 2022

Comments

  • AAnkit
    AAnkit almost 2 years

    I tried adding some files in Android framework. Everything goes well, except in the end of compilation i am getting below error.

    I tried make update-api too, but no luck, every time in compilation it is giving below errors. If anybody know how to overcome this, please let me know.

    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