@@ -28,6 +28,8 @@ public class DynamiteContext extends ContextWrapper {
2828 private Context gmsContext ;
2929 private DynamiteContext appContext ;
3030
31+ private ClassLoader classLoader ;
32+
3133 public DynamiteContext (DynamiteModuleInfo moduleInfo , Context base , Context gmsContext , DynamiteContext appContext ) {
3234 super (base );
3335 this .moduleInfo = moduleInfo ;
@@ -38,19 +40,22 @@ public DynamiteContext(DynamiteModuleInfo moduleInfo, Context base, Context gmsC
3840
3941 @ Override
4042 public ClassLoader getClassLoader () {
41- StringBuilder nativeLoaderDirs = new StringBuilder (gmsContext .getApplicationInfo ().nativeLibraryDir );
42- if (Build .VERSION .SDK_INT >= 23 && Process .is64Bit ()) {
43- for (String abi : Build .SUPPORTED_64_BIT_ABIS ) {
44- nativeLoaderDirs .append (File .pathSeparator ).append (gmsContext .getApplicationInfo ().sourceDir ).append ("!/lib/" ).append (abi );
45- }
46- } else if (Build .VERSION .SDK_INT >= 21 ) {
47- for (String abi : Build .SUPPORTED_32_BIT_ABIS ) {
48- nativeLoaderDirs .append (File .pathSeparator ).append (gmsContext .getApplicationInfo ().sourceDir ).append ("!/lib/" ).append (abi );
43+ if (classLoader == null ) {
44+ StringBuilder nativeLoaderDirs = new StringBuilder (gmsContext .getApplicationInfo ().nativeLibraryDir );
45+ if (Build .VERSION .SDK_INT >= 23 && Process .is64Bit ()) {
46+ for (String abi : Build .SUPPORTED_64_BIT_ABIS ) {
47+ nativeLoaderDirs .append (File .pathSeparator ).append (gmsContext .getApplicationInfo ().sourceDir ).append ("!/lib/" ).append (abi );
48+ }
49+ } else if (Build .VERSION .SDK_INT >= 21 ) {
50+ for (String abi : Build .SUPPORTED_32_BIT_ABIS ) {
51+ nativeLoaderDirs .append (File .pathSeparator ).append (gmsContext .getApplicationInfo ().sourceDir ).append ("!/lib/" ).append (abi );
52+ }
53+ } else {
54+ nativeLoaderDirs .append (File .pathSeparator ).append (gmsContext .getApplicationInfo ().sourceDir ).append ("!/lib/" ).append (Build .CPU_ABI );
4955 }
50- } else {
51- nativeLoaderDirs .append (File .pathSeparator ).append (gmsContext .getApplicationInfo ().sourceDir ).append ("!/lib/" ).append (Build .CPU_ABI );
56+ classLoader = new PathClassLoader (gmsContext .getApplicationInfo ().sourceDir , nativeLoaderDirs .toString (), new FilteredClassLoader (originalContext .getClassLoader (), moduleInfo .getMergedClasses (), moduleInfo .getMergedPackages ()));
5257 }
53- return new PathClassLoader ( gmsContext . getApplicationInfo (). sourceDir , nativeLoaderDirs . toString (), new FilteredClassLoader ( originalContext . getClassLoader (), moduleInfo . getMergedClasses (), moduleInfo . getMergedPackages ())) ;
58+ return classLoader ;
5459 }
5560
5661 @ Override
0 commit comments