A fully-featured client to access your Cloud Storage provided by MEGA.
This document provides step-by-step instructions to build the application on Linux and MacOS using Android Studio.
Install the following prerequisites:
Clone the repository with all submodules:
git clone --recursive https://github.com/meganz/android.git
Install Android NDK r27b (latest version tested: NDK r27b, version number: 27.1.12297006).
Export the NDK_ROOT environment variable or create a symbolic link at ${HOME}/android-ndk pointing to your Android NDK installation path:
export NDK_ROOT=/path/to/ndk
ln -s /path/to/ndk ${HOME}/android-ndk
Install NDK r27b using Android Studio by following these instructions. Pay attention to the bottom-right Show Package Details checkbox to display available versions. Latest version tested: NDK r27b, version number: 27.1.12297006.
Export the NDK_ROOT environment variable or create a symbolic link at ${HOME}/android-ndk pointing to your Android NDK installation path:
export NDK_ROOT="/Users/${USER}/Library/Android/sdk/ndk/27.1.12297006"
ln -s /path/to/ndk ${HOME}/android-ndk
Export the ANDROID_HOME environment variable or create a symbolic link at ${HOME}/android-sdk pointing to your Android SDK installation path:
export ANDROID_HOME=/path/to/sdk
ln -s /path/to/sdk ${HOME}/android-sdk
Export the ANDROID_HOME environment variable or create a symbolic link at ${HOME}/android-sdk pointing to your Android SDK installation path:
export ANDROID_HOME="/Users/${USER}/Library/Android/sdk/"
ln -s /path/to/sdk ${HOME}/android-sdk
Export the JAVA_HOME environment variable or create a symbolic link at ${HOME}/android-java pointing to your Java installation path.
You can find the Java path in Android Studio at Preferences > Build, Execution, Deployment > Build Tools > Gradle > Gradle JDK (default).
export JAVA_HOME=/path/to/jdk
ln -s /path/to/jdk ${HOME}/android-java
Export the JAVA_HOME environment variable or create a symbolic link at ${HOME}/android-java pointing to your Java installation path.
You can find the Java path in Android Studio at Preferences > Build, Execution, Deployment > Build Tools > Gradle > Gradle JDK (default).
Default MacOS path:
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/Contents/Home"
ln -s /path/to/jdk ${HOME}/android-java
sudo apt install python3-pkg-resources libglib2.0-dev libgtk-3-dev libasound2-dev libpulse-dev
Clone the VCPKG repository next to the Android repository folder. If you already have a local VCPKG clone, you can skip this step and use your existing VCPKG installation.
git clone https://github.com/microsoft/vcpkg
export VCPKG_ROOT=path/to/your/vcpkg/folder
Build the SDK by running ./cmake.sh from sdk/src/main/jni/.
IMPORTANT: Verify that the build process completes successfully. It should finish with the Task finished OK message. If it doesn't, modify the LOG_FILE variable in cmake.sh from /dev/stdout to a text file and run ./cmake.sh again to view the build errors.
⚠️ Deprecation Notice
This build process is obsolete, no longer maintained, and not supported.
It is kept only for Apple Silicon (ARM64) MacOS users, because the current SDK CMake-based build flow does not support Apple Silicon MacOS.
Last verified on: 2025-12-18
webrtc folder in sdk/src/main/jni/megachat/.sdk/src/main/jni/megachat/webrtc/libwebrtc.jar to sdk/libs/libwebrtc.jar (overwriting the committed jar) so that Gradle picks up the matching version.Note: The WebRTC download link may change over time. Please verify it matches the one specified in build.sh.
Before running the SDK build script, install the required dependencies via Homebrew:
brew install bash gnu-sed gnu-tar autoconf automake cmake coreutils libtool swig wget xz python3
Then reboot MacOS to ensure the newly installed bash (v5.x) overrides the default v3.x in PATH.
Edit your PATH environment variable (ensure GNU paths are set up before `$PATH):
~/.zshrc:export PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH"
export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
~/.zshrc:export PATH="/opt/homebrew/opt/gnu-tar/libexec/gnubin:$PATH"
export PATH="/opt/homebrew/opt/gnu-sed/libexec/gnubin:$PATH"
ln -s /opt/homebrew/bin/python3 /opt/homebrew/bin/python
Then install CMake version 3.22.1 in Android Studio > Tools > SDK Manager > SDK Tools > CMake.
You must check the Show Package Details checkbox to display this specific version. After installation, add the following line to ~/.zshrc:
export PATH="/Users/${USER}/Library/Android/sdk/cmake/3.22.1/bin:$PATH"
Build the SDK by running ./build.sh all from sdk/src/main/jni/. You can also run ./build.sh clean to clean the previous configuration.
IMPORTANT: Verify that the build process completes successfully. It should finish with the Task finished OK message. If it doesn't, modify the LOG_FILE variable in build.sh from /dev/null to a text file and run ./build.sh all again to view the build errors.
If you encounter an error (seen in the log file) due to licenses not being accepted, you can read and accept the licenses using the sdkmanager command-line tool:
/path-to-cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME --licenses
buildSrc/src/main/kotlin/mega/privacy/android/build/Util.kt and change the shouldUsePrebuiltSdk() method to:fun shouldUsePrebuiltSdk(): Boolean = false
// System.getenv("USE_PREBUILT_SDK")?.let { it != "false" } ?: true
settings.gradle.kts and change the shouldUsePrebuiltSdk() method to:fun shouldUsePrebuiltSdk(): Boolean = false
// System.getenv("USE_PREBUILT_SDK")?.let { it != "false" } ?: true
Note: You need to occasionally redo this section to ensure the latest analytics library is used.
git clone --recursive https://github.com/meganz/mobile-analytics.git
cd mobile-analytics
git checkout main
./gradlew --no-daemon assembleRelease
Copy the following generated libraries to the root of the MEGA codebase:
shared/build/outputs/aar/shared-release.aaranalytics-core/build/outputs/aar/analytics-core-release.aaranalytics-annotations/build/outputs/aar/analytics-annotations-release.aarModify MEGA code to depend on local AAR files:
implementation(lib.mega.analytics) throughout the project and replace all occurrences with the code below. Note: You may need to add .. to the path if the build.gradle.kts is in a subproject.// implementation(lib.mega.analytics)
implementation(files("../shared-release.aar"))
implementation(files("../analytics-core-release.aar"))
implementation(files("../analytics-annotations-release.aar"))
build.gradle.kts, comment out the following code:id("mega.android.release")
settings.gradle.kts, comment out the following code:maven {
url =
uri("${System.getenv("ARTIFACTORY_BASE_URL")}/artifactory/mega-gradle/megagradle")
}
and
resolutionStrategy {
eachPlugin {
if (requested.id.id == "mega.android.release") {
useModule("mega.privacy:megagradle:${requested.version}")
}
}
}
In lib.versions.toml, replace dependencies of Telephoto and uCrop with their publicly available versions from their official GitHub repositories.
app/src/gms/google-services.json.example to app/src/gms/google-services.jsonmega.privacy.android.app and mega.privacy.android.app.qagoogle-services.json with your project's configOpen the project with Android Studio, let it build the project, and click Run.
To use the geolocation feature, you need a Google Maps API key.
Placeholder google_maps_api.xml files with an empty key are already included in the repository. To enable geolocation:
Get an API key by following the directions here: https://developers.google.com/maps/documentation/android/signup
Once you have your key (it starts with "AIza"), replace the empty "google_maps_key" string in one of these files:
app/src/debug/res/values/google_maps_api.xmlapp/src/qa/res/values/google_maps_api.xmlapp/src/release/res/values/google_maps_api.xml