当前位置: 首页 > 工具软件 > MobileProject > 使用案例 >

Set up a MongoDB Mobile Project¶

雷飞虎
2023-12-01

MongoDB Logo
ServerDriversCloudToolsGuides
Get MongoDB
Close ×
MongoDB Stitch

Introduction
Tutorials
Users & Authentication
MongoDB Atlas
GraphQL
MongoDB Mobile
    Mobile Overview
    Usage Guides
        Set up a MongoDB Mobile Project
        Build a Mobile App with Sync
        Build a Local-Only Mobile App
    Reference
        MongoDB Mobile Features
        Java/Android SDK
        Swift/iOS SDK
Functions
Triggers
External Services
Values & Secrets
Application Deployment
Hosting
Troubleshooting
Stitch Administration
Application Logs
Client SDKs
Release Notes

Stitch > MongoDB Mobile > Usage Guides 

Set up a MongoDB Mobile Project

On this page

Overview
Check Your Environment
Procedure

Deprecation

MongoDB has deprecated MongoDB Mobile. We are focusing our efforts on Realm, the most popular database for mobile devices.

Stay up to date and see what we have planned.
Overview

Before you begin coding an Android or iOS app that uses MongoDB Mobile, there are a few short steps required to set up your project. The following sections discuss the prerequisites, and then show you how to prepare your project.
Check Your Environment

Android (Java) SDK iOS (Swift) SDK 

To build a Stitch app that uses MongoDB Mobile, you need:

Android Studio or another IDE. The steps below have been tested with the latest version of Android Studio.
Support for API Level 21 or higher.

We also recommend the following device capabilities:

An ARM32, ARM64, or x86_64 device that is running an armeabi-v7a, arm64-v8a, or x86_64 image of Android 5.0 (Lollipop) or later.

Supported Device Architectures

MongoDB Mobile does not support x86 devices. By default, Android Studio selects an x86 image for AVD deployments, so if you are deploying your Android app to an AVD, be sure to select an x86_64 image for the AVD. Otherwise, you will see an error message similar to the following:

com.mongodb.embedded.client.MongoClientEmbeddedException: Failed to load the mongodb library: ‘mongo_embedded_capi’. Native library (com/sun/jna/android-x86/libjnidispatch.so) not found in resource path (.)

Once these prerequisites are met, you are ready to start building your mobile app.
Procedure

To set up a new project that will use MongoDB Mobile, follow these steps:

Android (Java) SDK iOS (Swift) SDK 

Open a project in Android Studio, or create a new project. Be sure to set the minimum API level for the project to 21 or higher.

Add the following dependencies to the Module-level Build.gradle file:

implementation ‘org.mongodb:stitch-android-sdk:4.1.0’

In the android section of the same Module-level Build.gradle file, add the following compileOptions section:

compileOptions {
   sourceCompatibility = JavaVersion.VERSION_1_8
   targetCompatibility = JavaVersion.VERSION_1_8
}

Sync the application to incorporate these changes.

You can now use the Stitch SDKs to sync data between the local database and Atlas, or work with just the local database (MongoDB Mobile).
← Mobile Overview Build a Mobile App with Sync →

© MongoDB, Inc 2008-present. MongoDB, Mongo, and the leaf logo are registered trademarks of MongoDB, Inc.
Was this page helpful?
Yes
No

 类似资料:

相关阅读

相关文章

相关问答