{"id":14956481,"url":"https://github.com/mongodb/stitch-android-sdk","last_synced_at":"2025-11-11T21:01:33.900Z","repository":{"id":53128413,"uuid":"87100729","full_name":"mongodb/stitch-android-sdk","owner":"mongodb","description":"MongoDB Stitch Android SDK","archived":false,"fork":false,"pushed_at":"2023-04-10T12:52:34.000Z","size":3697,"stargazers_count":58,"open_issues_count":9,"forks_count":33,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-01-29T09:43:35.680Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mongodb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-03T17:19:42.000Z","updated_at":"2024-07-26T07:08:56.000Z","dependencies_parsed_at":"2024-08-23T00:02:02.626Z","dependency_job_id":"e588c91b-22c5-4920-853d-96b7cafb94de","html_url":"https://github.com/mongodb/stitch-android-sdk","commit_stats":null,"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fstitch-android-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fstitch-android-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fstitch-android-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fstitch-android-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongodb","download_url":"https://codeload.github.com/mongodb/stitch-android-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237088415,"owners_count":19253565,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T13:13:06.343Z","updated_at":"2025-10-19T07:31:06.470Z","avatar_url":"https://github.com/mongodb.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Join the chat at https://gitter.im/mongodb/stitch](https://badges.gitter.im/mongodb/stitch.svg)](https://gitter.im/mongodb/stitch?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n# Stitch SDK Deprecation Notice\n\nStitch SDK functionality has been moved into the Realm SDKs. Applications using a Stitch SDK can be migrated to the corresponding Realm SDK by using one of the [Stitch SDK Migration Guides](https://docs.mongodb.com/realm/migrate). **Support for the Stitch SDKs will fully end on November 1, 2021.**\n\n# MongoDB Stitch Android/Java SDK \n\nThe official [MongoDB Stitch](https://stitch.mongodb.com/) SDK for Android/Java.\n\n### Index\n- [Documentation](#documentation)\n- [Discussion](#discussion)\n- [Installation](#installation)\n- [Example Usage](#example-usage)\n\n## Documentation\n* [API/Javadoc Documentation](https://docs.mongodb.com/stitch-sdks/java/4.7.0/index.html)\n* [MongoDB Stitch Documentation](https://docs.mongodb.com/stitch/)\n\n## Discussion\n* [MongoDB Stitch Users - Google Group](https://groups.google.com/d/forum/mongodb-stitch-users)\n* [MongoDB Stitch Announcements - Google Group](https://groups.google.com/d/forum/mongodb-stitch-announce)\n\n## Installation\n\nThe SDK artifacts are hosted by JCenter/Bintray at https://bintray.com/mongodb/MongoDB. Use the `jcenter() and mavenCentral()` repositories to get these artifacts.\n\n### Android\n\nAdd the following to the build.gradle for your app module:\n\n```gradle\nimplementation 'org.mongodb:stitch-android-sdk:4.7.0'\n```\n\nAlso add the following to your android block in your app module:\n\n```gradle\ncompileOptions {\n    sourceCompatibility = JavaVersion.VERSION_1_8\n    targetCompatibility = JavaVersion.VERSION_1_8\n}\n```\n\nThis will start you off with the core SDK functionality as well as the remote MongoDB service.\n\nFor customized dependencies use the following:\n\n```gradle\nimplementation 'org.mongodb:stitch-android-core:4.7.0'\nimplementation 'org.mongodb:stitch-android-services-aws:4.7.0'\nimplementation 'org.mongodb:stitch-android-services-fcm:4.7.0'\nimplementation 'org.mongodb:stitch-android-services-http:4.7.0'\nimplementation 'org.mongodb:stitch-android-services-mongodb-remote:4.7.0'\nimplementation 'org.mongodb:stitch-android-services-twilio:4.7.0'\n```\n\n#### R8 / ProGuard\n\nFor Android applications with ProGuard and minify enabled, the Stitch SDK provides a consumer ProGuard rules file that will automatically be applied when including the SDK.\n\nIf you experience any ProGuard related warnings or error when using the Stitch SDK with an application where minify is enabled, try manually adding the rules in [android/core/lib-proguard-rules.pro](android/core/lib-proguard-rules.pro) to your application's `proguard-rules.pro` file. If that doesn't work, please open an issue on this repository.\n\n### Server/Java\n\nAdd the following to the build.gradle for your module:\n\n```gradle\nimplementation 'org.mongodb:stitch-server-sdk:4.7.0'\n```\n\nThis will start you off with the core SDK functionality as well as the remote MongoDB service.\n\nFor customized dependencies use the following:\n\n```gradle\nimplementation 'org.mongodb:stitch-server-core:4.7.0'\nimplementation 'org.mongodb:stitch-server-services-aws:4.7.0'\nimplementation 'org.mongodb:stitch-server-services-fcm:4.7.0'\nimplementation 'org.mongodb:stitch-server-services-http:4.7.0'\nimplementation 'org.mongodb:stitch-server-services-mongodb-remote:4.7.0'\nimplementation 'org.mongodb:stitch-server-services-twilio:4.7.0'\n```\n\n## Example Usage\n\n### Creating a new app with the SDK (Android)\n\n#### Set up an application on Stitch\n1. Go to [https://stitch.mongodb.com/](https://stitch.mongodb.com/) and log in to MongoDB Atlas.\n2. Create a new app in your project with your desired name.\n3. Go to your app in Stitch via Atlas by clicking Stitch Apps in the left side pane and clicking your app.\n3. Copy your app's client app id by going to Clients on the left side pane and clicking copy on the App ID section.\n4. Go to Providers from Users in the left side pane and edit and enable \"Allow users to log in anonymously\".\n\n#### Set up a project in Android Studio using Stitch\n1. Download and install [Android Studio](https://developer.android.com/studio/index.html).\n2. Start a new Android Studio project.\n\t* Note: The minimum supported API level is 21 (Android 5.0 Lollipop)\n\t* Starting with an empty activity is ideal\n3. In your build.gradle for your app module, add the following to your dependencies block:\n\n\t```gradle\n    implementation 'org.mongodb:stitch-android-sdk:4.7.0'\n    ```\n4. In your build.gradle for your app module, add the following to your android block:\n\n    ```gradle\n    compileOptions {\n        sourceCompatibility = JavaVersion.VERSION_1_8\n        targetCompatibility = JavaVersion.VERSION_1_8\n    }\n    ```\n5. Android Studio will prompt you to sync your changes in your project; hit Sync Now.\n\n#### Set up an Android Virtual Device\n\n1. In Android Studio, go to Tools, Android, AVD manager.\n2. Click Create Virtual Device.\n3. Select a device that should run your app (as of Android Studio 3.2, the default device does not work properly for this purpose).\n4. Select and download a recommended system image of your choice (the latest is fine).\n    * This device must use a system image built on an architecture supported by the\n```libmongo``` library, e.g. x86_64\n        * x86 images are unsupported\n        * x86_64 images are available in the x86 tab.\n    * The current minimum Android API version: 21\n    * Please consult the the [MongoDB Mobile Documentation](https://docs.mongodb.com/stitch/mongodb/mobile/getting-started/) for more information about minimum device requirements.\n5. Name your device and hit finish.\n\n#### Using the SDK\n\n##### Set up app info\n1. Create a resource values file in your app (e.g. res/values/mongodb-stitch.xml) and set the following using the app id you copied earlier in place of YOUR_APP_ID:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cresources\u003e\n    \u003cstring name=\"stitch_client_app_id\"\u003eYOUR_APP_ID\u003c/string\u003e\n\u003c/resources\u003e\n```\n\n##### Logging In\n1. Since we enabled anonymous log in, let's log in with it; add the following anywhere in your code:\n\n  ```java\n    final StitchAppClient client = Stitch.getDefaultAppClient();\n    client.getAuth().loginWithCredential(new AnonymousCredential()).addOnCompleteListener(\n        new OnCompleteListener\u003cStitchUser\u003e() {\n          @Override\n          public void onComplete(@NonNull final Task\u003cStitchUser\u003e task) {\n            if (task.isSuccessful()) {\n              Log.d(\"myApp\", String.format(\n                  \"logged in as user %s with provider %s\",\n                  task.getResult().getId(),\n                  task.getResult().getLoggedInProviderType()));\n            } else {\n              Log.e(\"myApp\", \"failed to log in\", task.getException());\n            }\n          }\n    });\n  ```\n\n2. Now run your app in Android Studio by going to run, Run 'app'. Use the Android Virtual Device you created previously\n3. Once the app is running, open up Logcat in the bottom of Android studio and you should see the following log message:\n\n\t```\n\tlogged in as user 5b0483778f25b978044aca76 with provider anon-user\n\t```\n\t\n##### Getting a StitchAppClient without Stitch.getDefaultAppClient\n\nIn the case that you don't want a default initialized [StitchAppClient](https://docs.mongodb.com/stitch-sdks/java/4/com/mongodb/stitch/android/core/StitchAppClient.html) by setting up the resource values, you can use the following code once to initialize a client for a given app id that you copied earlier:\n\n```java\nfinal StitchAppClient client = Stitch.initializeAppClient(\"YOUR_APP_ID\");\n```\n\nYou can use the client returned there or anywhere else in your app you can use the following:\n\n```java\nfinal StitchAppClient client = Stitch.getAppClient(\"YOUR_APP_ID\");\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb%2Fstitch-android-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongodb%2Fstitch-android-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb%2Fstitch-android-sdk/lists"}