forked from geode-sdk/android-launcher
initial files
This commit is contained in:
63 files changed
+2268
No files matched your search
@@ -0,0 +1,9 @@
|
||||
package com.robtopx.geometryjump
|
||||
|
||||
object GJConstants {
|
||||
const val PACKAGE_NAME = "com.robtopx.geometryjump"
|
||||
|
||||
const val COCOS_LIB_NAME = "cocos2dcpp"
|
||||
const val FMOD_LIB_NAME = "fmod"
|
||||
const val MOD_CORE_LIB_NAME = "geode"
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.robtopx.geometryjump
|
||||
|
||||
import dalvik.system.BaseDexClassLoader
|
||||
import java.io.File
|
||||
|
||||
object LaunchUtils {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun addDirectoryToClassPath(directory: String, classLoader: ClassLoader) {
|
||||
// uses code from zhuowei/MCPELauncher
|
||||
try {
|
||||
val clazz = classLoader.javaClass
|
||||
val plField = clazz.superclass.getDeclaredField("pathList")
|
||||
plField.isAccessible = true
|
||||
|
||||
val pathListInst = plField.get(classLoader)
|
||||
val pathListClazz = pathListInst.javaClass
|
||||
val nldField = pathListClazz.getDeclaredField("nativeLibraryDirectories")
|
||||
nldField.isAccessible = true
|
||||
|
||||
val pathList = nldField.get(pathListInst)
|
||||
|
||||
println(pathList)
|
||||
|
||||
if (pathList is ArrayList<*>) {
|
||||
// no safe way to check this type afaik, so casting is needed
|
||||
(pathList as ArrayList<File>).add(
|
||||
File(directory)
|
||||
)
|
||||
}
|
||||
|
||||
if (classLoader is BaseDexClassLoader && classLoader.findLibrary(GJConstants.COCOS_LIB_NAME) == null) {
|
||||
val anpMethod = pathListClazz.getDeclaredMethod("addNativePath", Collection::class.java)
|
||||
|
||||
anpMethod.invoke(
|
||||
pathListInst,
|
||||
listOf(directory)
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user