Java Question desugar - fix the "invokedynamic requires" error

Discussion in 'Libraries developers questions' started by Erel, Jul 2, 2019.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Some of the new Android libraries use Java 8 features. Android doesn't natively support those features so they must be removed (desugared) at some point.

    When you wrap a library that includes such features you need to desugar the wrapped library. This is done with an Android tool named desugar.

    It can be downloaded from here: www.b4x.com/android/files/Desugar_deploy.jar
    This input of this tool is a jar file and the output is a "desugared" jar. You need to do it once and then use the desugared jar.

    The latest version of ExoPlayer depends on 7 AAR packages. Desugaring these packages requires several steps:
    - Extract the inner classes.jar from each AAR.
    - Desugar it.
    - Put it back or remove the original one.

    To make things easier I wrote a small B4J app that does the following steps:
    - Extracts all classes.jar and merges them to a single jar.
    - The classes.jar files are removed from the AAR files.
    - The merged jar is desugared.

    Go over the code before you use it.
    Note that it calls zip info: http://infozip.sourceforge.net/Zip.html#Release
    If the classes.jar depend on other libraries then you will need to add references by adding additional --bootclasspath_entry parameters.
     

    Attached Files:

  2. Alberto Iglesias

    Alberto Iglesias Well-Known Member Licensed User

    This working fine for my next library! Thank you!
     
    Erel likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice