This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Classes.jar is the input file being run through the dex process | |
dx --dex --output "dexFile.dex" classes.jar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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. | |
*/ | |
OlderNewer