0

The android dev site documentation for java.lang.Package is a close copy of the Java Platform SE 8 docs, but the behavior at runtime is very different for libraries loaded from a jar.

I have checked a handful of the versioning attributes documented in https://docs.oracle.com/javase/7/docs/technotes/guides/jar/jar.html#Main_Attributes (ImplementationVersion, ImplementationVendor, SpecificationTitle) and all of them return the correct data from the Manifest when running with the openjdk JRE on my desktop, but well-formed but incorrect data on the platform.

import com.example.roscoe.Roscoe;

public class Hello {
    public static void main(String[] argv) {
    Package p = Roscoe.class.getPackage();
    System.out.println(p.getName());
    System.out.println(p.getImplementationVersion());
    }
}

Is there anything I can do at the 'converting jar into dex' stage of compilation to cause the manifest data to be available at runtime?

Edit to add:

Why does this even matter First, I'm a prescriptivist and it is documented to work, so it should work.

Second, we are at a stage where no two testers have the same version of a fast-moving library and we really want to have the library version in the About Box for the application.

  • You do have a Newline at the end of your Manifest File, don't you? – keuleJ Nov 06 '19 at 19:05
  • This question is duplicate, try checking here https://stackoverflow.com/questions/33553570/how-to-read-meta-data-from-manifest-file – OMi Shah Nov 06 '19 at 19:08
  • @keuleJ - yes - remember - reading the metadata from the JRE works ... only reading from the jar after it's gone through Android's "mangling" fails. – Lawrence NK1G Nov 06 '19 at 19:35
  • @OMiShah - not a dupe of that -- his problem was not on the android platform -- and I'm not getting `null` -- nor even the string "(null)" -- but the string "Unknown" for the attributes that are textual, and the string "0.0" for the version numbers. – Lawrence NK1G Nov 06 '19 at 19:36
  • Okay. Sorry, my mistake – OMi Shah Nov 07 '19 at 19:37

0 Answers0