hi am unable to load class in my android app , i can load basic class but when i Initialize context in that class then am not able to load it
public class main {
// Initalize context
Context mContext;
public main(Context mContext){
this.mContext = mContext;
}
public boolean main() {
Log.d("MYLOG", "main() called successfully when there context is not initialized like above");
// some code here
}
}
my class loading code
try{
final File tmpDir = context.getDir("dex", 0);
final DexClassLoader classloader = new DexClassLoader(libPath, tmpDir.getAbsolutePath(), null, this.getClass().getClassLoader());
final Class<Object> classToLoad = (Class<Object>) classloader.loadClass("com.myproject.test.dumy_class"); // package plus main class
final Object myInstance = classToLoad.newInstance(); // throwing exception here
}
} catch (Exception e) {
// exception thrown at that statement : final Object myInstance = classToLoad.newInstance();
}
Exception i got :
java.lang.InstantiationException: can't instantiate class com.myproject.test.dumy_class; no empty constructor
so please help .