Skip to content

Instantly share code, notes, and snippets.

class ModuleLoader(val cacheDir: String) {
fun load(dex: File, cls: String = "com.example.dynamicmodule.DynamicModule"): IDynamicModule {
try {
val classLoader = DexClassLoader(dex.absolutePath, cacheDir,
null, this.javaClass.classLoader)
val moduleClass = classLoader.loadClass(cls)
if (IDynamicModule::class.java.isAssignableFrom(moduleClass)) {
# Classes.jar is the input file being run through the dex process
dx --dex --output "dexFile.dex" classes.jar
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
text_view.text = loadDexFile("dm.dex").text
textView2.text = loadDexFile("dm2.dex").text
}
@davethomas11
davethomas11 / when_in.kt
Created March 4, 2018 18:41
You can use the in keyword in Kotlin with any class that implements operator contains
/**
* Using in keyword with other classes in Kotlin.
* ----------------------------------------------
*
*
* You can provide an operator contains function for a class so
* that you can use the in syntax in a when statement.
*/