From 0483173bb73735c957e7a127e1031d5d0914e3de Mon Sep 17 00:00:00 2001 From: galenlin Date: Tue, 24 Apr 2018 09:31:25 +0800 Subject: [PATCH] Construct the dexElement with plugin file path on API 26+, so that can find the resource in it. Fix #574 --- .../net/wequick/small/util/ReflectAccelerator.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Android/DevSample/small/src/main/java/net/wequick/small/util/ReflectAccelerator.java b/Android/DevSample/small/src/main/java/net/wequick/small/util/ReflectAccelerator.java index a771d19a..922ee4ad 100644 --- a/Android/DevSample/small/src/main/java/net/wequick/small/util/ReflectAccelerator.java +++ b/Android/DevSample/small/src/main/java/net/wequick/small/util/ReflectAccelerator.java @@ -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) { @@ -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: