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_ROOTenvironment variable or create a symbolic link at${HOME}/android-ndkpointing 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 Detailscheckbox to display available versions. Latest version tested: NDK r27b, version number: 27.1.12297006. -
Export the
NDK_ROOTenvironment variable or create a symbolic link at${HOME}/android-ndkpointing 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-ndkExport 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-sdkExport 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-sdkExport 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-javaExport 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-javasudo apt install python3-pkg-resources libglib2.0-dev libgtk-3-dev libasound2-dev libpulse-devClone 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/folderBuild 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 NoticeThis 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
- Download the WebRTC files from: https://mega.nz/file/N2k2XRaA#bS9iudrjiULmMaGbBKErsYosELbnU22b8Zj213Ti1nE
- Uncompress the archive and place the
webrtcfolder insdk/src/main/jni/megachat/.
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 python3Then 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):
- For Intel chip, add the following lines to
~/.zshrc:
export PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH"
export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"- For Apple Silicon, add the following lines to
~/.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/pythonThen 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 --licensesDownload the required files from: https://mega.nz/#!1tcl3CrL!i23zkmx7ibnYy34HQdsOOFAPOqQuTo1-2iZ5qFlU7-k
Uncompress the archive and place the debug and release folders in app/src/.
- Open
buildSrc/src/main/kotlin/mega/privacy/android/build/Util.ktand change theshouldUsePrebuiltSdk()method to:
fun shouldUsePrebuiltSdk(): Boolean = false
// System.getenv("USE_PREBUILT_SDK")?.let { it != "false" } ?: true- Open
settings.gradle.ktsand change theshouldUsePrebuiltSdk()method to:
fun shouldUsePrebuiltSdk(): Boolean = false
// System.getenv("USE_PREBUILT_SDK")?.let { it != "false" } ?: trueNote: You need to occasionally redo this section to ensure the latest analytics library is used.
- Download and build the Mobile Analytics source code:
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.aar
-
Modify MEGA code to depend on local AAR files:
- Search for
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 thebuild.gradle.ktsis in a subproject.
- Search for
// implementation(lib.mega.analytics)
implementation(files("../shared-release.aar"))
implementation(files("../analytics-core-release.aar"))
implementation(files("../analytics-annotations-release.aar"))- In the root
build.gradle.kts, comment out the following code:
id("mega.android.release")- In
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.
Open 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:
-
To get one, follow the directions here: https://developers.google.com/maps/documentation/android/signup
-
Once you have your key, replace the
"google_maps_key"string in these files:app/src/debug/res/values/google_maps_api.xmlapp/src/release/res/values/google_maps_api.xml