| 164 | #if defined(__ANDROID__) |
| 165 | typedef jint (*JNI_CreateJavaVM_t)(JavaVM **, JNIEnv **, void *); |
| 166 | JNI_CreateJavaVM_t LoadAndroidVMLibs() { |
| 167 | std::cout << "Loading Android libraries" << std::endl; |
| 168 | |
| 169 | void *art_so = nullptr; |
| 170 | art_so = dlopen("libnativehelper.so", RTLD_NOW); |
| 171 | |
| 172 | if (art_so == nullptr) { |
| 173 | std::cerr << "Could not find ART library" << std::endl; |
| 174 | exit(1); |
| 175 | } |
| 176 | |
| 177 | typedef void *(*JniInvocationCreate_t)(); |
| 178 | JniInvocationCreate_t JniInvocationCreate = |
| 179 | reinterpret_cast<JniInvocationCreate_t>( |
| 180 | dlsym(art_so, "JniInvocationCreate")); |
| 181 | if (JniInvocationCreate == nullptr) { |
| 182 | std::cout << "JniInvocationCreate is null" << std::endl; |
| 183 | exit(1); |
| 184 | } |
| 185 | |
| 186 | void *impl = JniInvocationCreate(); |
| 187 | typedef bool (*JniInvocationInit_t)(void *, const char *); |
| 188 | JniInvocationInit_t JniInvocationInit = |
| 189 | reinterpret_cast<JniInvocationInit_t>(dlsym(art_so, "JniInvocationInit")); |
| 190 | if (JniInvocationInit == nullptr) { |
| 191 | std::cout << "JniInvocationInit is null" << std::endl; |
| 192 | exit(1); |
| 193 | } |
| 194 | |
| 195 | JniInvocationInit(impl, nullptr); |
| 196 | |
| 197 | constexpr char create_jvm_symbol[] = "JNI_CreateJavaVM"; |
| 198 | typedef jint (*JNI_CreateJavaVM_t)(JavaVM **, JNIEnv **, void *); |
| 199 | JNI_CreateJavaVM_t JNI_CreateArtVM = |
| 200 | reinterpret_cast<JNI_CreateJavaVM_t>(dlsym(art_so, create_jvm_symbol)); |
| 201 | if (JNI_CreateArtVM == nullptr) { |
| 202 | std::cout << "JNI_CreateJavaVM is null" << std::endl; |
| 203 | exit(1); |
| 204 | } |
| 205 | |
| 206 | return JNI_CreateArtVM; |
| 207 | } |
| 208 | #endif |
| 209 | |
| 210 | std::string GetClassPath() { |