uniQ
uniQ

Reputation: 125

Unable to Load Library mongo_embedded

I am trying to use MongoDB in an Android project by following this guide:
https://docs.mongodb.com/stitch/mongodb/find-documents-in-mongodb/

But the application is crashing at the following line:
val mongoClient = stitchClient.getServiceClient(RemoteMongoClient.factory, "mongodb-atlas")
with the following message

com.mongodb.embedded.client.MongoClientEmbeddedException: The mongo embedded library could not be initialized
    Server error message: Unable to load the Mongo Embedded Library.
    Please either: Set the libraryPath when calling MongoEmbeddedCAPI.create or 
    Ensure the library is set on the jna.library.path or the java.library.path system property.
....
....
Caused by: java.lang.UnsatisfiedLinkError: Unable to load library 'mongo_embedded': Native library (android-x86/libmongo_embedded.so) not found in resource path (.)

But when I run the application on my phone it is working. Any ideas why it is crashing on the virtual emulator.

Upvotes: 0

Views: 361

Answers (1)

Zasekle
Zasekle

Reputation: 57

The reason the client is crashing is because the mongoDB stitch SDK needs to run on a 64 bit device (see Here). Almost all android devices built now are 64 bit however the emulator in android studio is 32 bit by default.

To fix this go to the AVD Manager and create a new Virtual Device that supports x86_64 (this is 64 bit) instead of x86 (this is 32 bit).

Upvotes: 1

Related Questions