Search code examples
androidandroid-sourcedalvik

Android making duplicate .dex files of apk's in dalvik-cache


I am developing a product based on Android AOSP 4.4.2 running on custom hardware. I have a separate partition /opt and my apk's are stored in /opt/harsh/app/ . I also have a symlink /vendor which points to /opt/harsh (this is required as per the design structure).

The issue I'm facing is that there are multiple .dex files created in /data/dalvik-cache for /opt/harsh/app/*.apk and /vendor/app/*.apk which are the same files, but both of these set of .dex files have different user groups. Because of this my applications are not running properly. If I make change to not create /opt partition and only create /vendor partition instead of symlink and put apk's in it, everything works fine.

Pls help ...


Solution

  • Finally I solved the issue myself !

    There is a bug in libcore/dalvik/src/main/java/dalvik/system/DexFile.java which caused this issue. Here in this function :

    private static int openDexFile(String sourceName, String outputName,
        int flags) throws IOException {
        return openDexFileNative(new File(sourceName).getCanonicalPath(),
                                 (outputName == null) ? null : new File(outputName).getCanonicalPath(),
                                 flags);
    }
    

    The issue is in new File(sourceName).getCanonicalPath()

    By changing it to new File(sourceName).getAbsolutePath() the issue is solved