diff options
author | Yohann Roussel <yroussel@google.com> | 2014-11-28 15:41:55 +0100 |
---|---|---|
committer | Yohann Roussel <yroussel@google.com> | 2014-12-02 10:17:11 +0100 |
commit | 8c2abf7f471b061b737e700af711e9d5d6883b40 (patch) | |
tree | 2a05b4ad1eb703e58e47692856d71113f33824f3 | |
parent | ddd65a611834d9a9222603b2e85d558265f0aa85 (diff) | |
download | multidex-lollipop-wear-release.tar.gz |
Workaround mkdirs concurency problemsandroid-wear-5.0.0_r1lollipop-wear-release
Use only mkdir since our usage is a simple case.
Bug: https://code.google.com/p/android/issues/detail?id=79388
Change-Id: Iab7504f3c38c660f93ab1249895be454af5ff84d
-rw-r--r-- | library/src/android/support/multidex/MultiDexExtractor.java | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/library/src/android/support/multidex/MultiDexExtractor.java b/library/src/android/support/multidex/MultiDexExtractor.java index b5973c5..27da6b3 100644 --- a/library/src/android/support/multidex/MultiDexExtractor.java +++ b/library/src/android/support/multidex/MultiDexExtractor.java @@ -253,10 +253,12 @@ final class MultiDexExtractor { */ private static void prepareDexDir(File dexDir, final String extractedFilePrefix) throws IOException { - dexDir.mkdirs(); - if (!dexDir.isDirectory()) { - throw new IOException("Failed to create dex directory " + dexDir.getPath()); - } + /* mkdirs() has some bugs, especially before jb-mr1 and we have only a maximum of one parent + * to create, lets stick to mkdir(). + */ + File cache = dexDir.getParentFile(); + mkdirChecked(cache); + mkdirChecked(dexDir); // Clean possible old files FileFilter filter = new FileFilter() { @@ -282,6 +284,24 @@ final class MultiDexExtractor { } } + private static void mkdirChecked(File dir) throws IOException { + dir.mkdir(); + if (!dir.isDirectory()) { + File parent = dir.getParentFile(); + if (parent == null) { + Log.e(TAG, "Failed to create dir " + dir.getPath() + ". Parent file is null."); + } else { + Log.e(TAG, "Failed to create dir " + dir.getPath() + + ". parent file is a dir " + parent.isDirectory() + + ", a file " + parent.isFile() + + ", exists " + parent.exists() + + ", readable " + parent.canRead() + + ", writable " + parent.canWrite()); + } + throw new IOException("Failed to create cache directory " + dir.getPath()); + } + } + private static void extract(ZipFile apk, ZipEntry dexFile, File extractTo, String extractedFilePrefix) throws IOException, FileNotFoundException { |