Monday, January 22, 2018

Android studio Failed to load class dynamically

after moving to Android Studio we noticed that we get failed to load class dynamically.
via such code below:

ClassLoader cl = getClassLoader();
Class classToInvestigate = df.loadClass(className, cl);

in out case we needed to remove (disbaled) the instant run , and in the class name 
we needed to change from string ("com.xx.yy.teston") to getCanonicalName()
e.g. com.xx.yy.teston.class.getCanonicalName()

here how i disabled the instant run 
i hope you will find it useful. 


also some info you can see here 
https://stackoverflow.com/questions/36881299/java-lang-classnotfoundexception-after-android-studio-update
enjoy 
Yaniv Tzanany