2

Is there any way to tell these two files apart? They're both identified as zip files using the command file, so is there a way to tell them apart? (Disregarding extension of course).

NOTE: Trying to perform file analysis, both these files run through different analysis so I have to be able to tell them apart.

1
  • Not possible afaik.
    – Rinzwind
    Jul 23, 2012 at 14:37

5 Answers 5

3

APK file is just a JAR file with additional Android platform specific files included in it such as AndroidManifest.xml and classes.dex.

JAR file is just a compressed ZIP file with additional metadata (MANIFEST.MF etc.) in a folder (META-INF).

ZIP file is a compressed single-file representation of a folder.

So, in a nut-shell all 3 formats are essentially just a ZIPped folder with additional format-specific metadata files.

Use Android SDK's dx utility to generate all 3 formats from the same helloWorld.java file, then hexDump the 3 files, then diff them 2 at a time to confirm that they are nearly identical with 4 format-specific bytes being different. All other bytes are identical in the 3 generated files.

1

Not with official tools, probably not at all.

The DEX files are files converted in a language that the Dalvik machine can understand and execute, not necessarily java, the DEXs are just intermediary files targeting the Dalvik virtual machine, so technically speaking there is also no garanty that this DEX files are from a jar or from the java language.

At building time, when the apk is created, all the code that is not a native library is put in a DEX files. The "jar idea" simply doesn't exist and does not live in an apk file.

2
  • In general, I'm just trying to differentiate between all sorts of zip files. been trying to do the same for MSOffice 2007+ files as well
    – Shelby. S
    Jul 23, 2012 at 14:33
  • to make a local database? just look at the extension of the file in this case, or make a script that will open the apk and look for a DEX file to ensure you that that file is a real apk.
    – user827992
    Jul 23, 2012 at 14:37
1

APK (Android application package) is the file format used to distribute and install application software for the Android operating system. It can only be used with the Android OS.

JAR (Java Archive) is a archive file format typically used to distribute a set of Java classes. These files are done using the ZIP file format and have the .jar file extension. They can be used on multiple devices including those that have the Android OS.

You can convert apk to jar, and vice versa.

APK files are saved in a compressed .ZIP format and can be opened by any Zip decompression tool. You can either rename the file extension to ".zip" and open the file

Jar file compresses and contains other files. Jar files are very easy to open. There are many programs that will open jar files. In fact, any program that can open zip files can open jar files. The jar format is identical to the zip file format. Java runtime environment is needed to open Jar files.

To open APK files on your computer, additional software is needed.

1
  • I'm trying to perform file analysis... So I have to be able to tell these files apart
    – Shelby. S
    Jul 23, 2012 at 14:25
0

apk files are only used by Android (program installers) and jar files are used on Java plateforms in general. You can see it with their meaning :

  • apk : Android PacKage
  • jar : Java ARchive
1
  • Trying to perform file analysis, different analysis for jar files and different for apk files
    – Shelby. S
    Jul 23, 2012 at 14:25
0

Your best bet would be to check the contents of the zip file. All .apk files should contain an AndroidManifest.xml file, so the presence of that file in the ZIP index should be a pretty good indicator you have a file of that type.

For .jar files, checking for META-INF/MANIFEST.MF in the ZIP index is probably the best option. Note that Android packages also include this manifest, so check if the file is a .apk file first.

You can use similar tricks for other ZIP based formats. For example, Open Document Format files include a file mimetype whose contents should tell you the particular type of the file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .