Skip to content

Commit

Permalink
Construct the dexElement with plugin file path on API 26+, so that ca…
Browse files Browse the repository at this point in the history
…n find the resource in it. Fix #574
  • Loading branch information
galenlin committed Apr 24, 2018
1 parent 04f08ae commit 0483173
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ private static Object makeDexElement(File pkg, boolean isDirectory, DexFile dexF
sDexElementClass = Class.forName("dalvik.system.DexPathList$Element");
}
if (sDexElementConstructor == null) {
sDexElementConstructor = sDexElementClass.getConstructors()[0];
if (Build.VERSION.SDK_INT >= 26) {
sDexElementConstructor = sDexElementClass.getConstructors()[1]; // (DexFile, File)
} else {
sDexElementConstructor = sDexElementClass.getConstructors()[0];
}
}
Class<?>[] types = sDexElementConstructor.getParameterTypes();
switch (types.length) {
Expand All @@ -207,10 +211,10 @@ private static Object makeDexElement(File pkg, boolean isDirectory, DexFile dexF
// Element(File apk, File zip, DexFile dex)
return sDexElementConstructor.newInstance(pkg, pkg, dexFile);
}
case 1:
case 2:
if (Build.VERSION.SDK_INT >= 26) {
//Only SDK >= 26
return sDexElementConstructor.newInstance(dexFile);
return sDexElementConstructor.newInstance(dexFile, pkg);
}
case 4:
default:
Expand Down

0 comments on commit 0483173

Please sign in to comment.