Skip to content

Dynamically load class from jar at runtime from anywhere on android

Notifications You must be signed in to change notification settings

sirmordred/JarClassLoader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

JarClassLoader

Dynamically load class from jar at runtime from anywhere on android

How-to-use:

Import JarClassLoader.aar into your project (File->new->import module->import .aar)

After that import the following class

    import com.mordred.jarclassloader.Loader;

and then use the following method

    Loader.getClassFromJar(Context ctx,String jarLocation,String classPath);

    ctx = use getApplicationContext();

    jarLocation = /storage/emulated... or /storage/sdcard.. or File.getAbsolutePath()
    (note that in some cases like reading from sd on android, you also need READ_PERMISSION to read that jar)
    
    classPath = inside your jar, choose which class you want to get/instantiate (with package name) (e.g com.xyz.FooClass)

It'll return Class<?> type object

voila.... you get your class object from your jar file and you can use that object to invoke methods or get/set variables etc. (i assume you know basics of reflection)

Happy coding guys...

source will be released when i get some time, stay tuned ;)

About

Dynamically load class from jar at runtime from anywhere on android

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published