'encrypt android smali and load it during runtime

I want to protect android applications and add a DRM to apks, I first decompile the apk and remove some of its smali files randomly, then I use smali2dex and dex2jar or minified apk to keen the randomly selected classes inside it for encryption.


I load the classes at runtime using dexclassloader and add the location of jar/apk but the system seems not to resolve this.

ClassLoader layerP = new MyDexClassLoader(this, dexPath, getFilesDir().getAbsolutePath(),
                    (ClassLoader) sm.get())

the I set it as default class laoder using reflection


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source