How to Build the MEGA Android Client Application

Jul 23, 2022 | Programming

Welcome to your one-stop guide for building the MEGA Android Client Application on a Linux or macOS machine using Android Studio. If you’re ready to access your cloud storage in a fully-featured manner, follow these steps diligently.

1. Setting Up Your Development Environment

Before diving into building your application, ensure you have the following essentials:

2. Building and Running the Application

Once your environment is ready, grab the source code using the following command:

git clone --recursive https://github.com/meganz/android.git

3. NDK Configuration

3.1 For Linux Users

  • Install the Android NDK (latest tested: NDK r21d, version number: 21.3.6528147).
  • Set up the NDK_ROOT environment variable or create a symbolic link.
  • export NDK_ROOT=path_to_ndk
    ln -s path_to_ndk $HOME/android-ndk

3.2 For macOS Users

  • Open Android Studio and install NDK r21d following these instructions.
  • If necessary, set the NDK_ROOT and create a symbolic link.
  • export NDK_ROOT=/Users/$USER/Library/Android/sdk/ndk/21.3.6528147
    ln -s path_to_ndk $HOME/android-ndk

4. Configuring ANDROID_HOME

4.1 For Linux

  • Export ANDROID_HOME variable or create a symbolic link.
  • export ANDROID_HOME=path_to_sdk
    ln -s path_to_sdk $HOME/android-sdk

4.2 For macOS

  • Set ANDROID_HOME as needed, as shown:
  • export ANDROID_HOME=/Users/$USER/Library/Android/sdk
    ln -s path_to_sdk $HOME/android-sdk

5. Configuring JAVA_HOME

5.1 For Linux

  • Export JAVA_HOME variable.
  • export JAVA_HOME=path_to_jdk
    ln -s path_to_jdk $HOME/android-java

5.2 For macOS

  • Set up JAVA_HOME in the same manner as shown for Linux.
  • export JAVA_HOME=/Applications/Android Studio.app/Contents/jre/Contents/Home
    ln -s path_to_jdk $HOME/android-java

6. Download WEBRTC Files

Next, download WEBRTC files from this link. Uncompress it and place the folder in sdksrcmainjni/megachat.

7. Prerequisites for Running the Build Script

7.1 For Linux

  • Install required packages, particularly on Ubuntu or similar:
  • sudo apt install build-essential swig automake libtool autoconf cmake ninja-build
  • Make sure CMake version 3.22.1 is installed in Android Studio.

7.2 For macOS

  • Install dependencies via HomeBrew as advised:
  • brew install bash gnu-sed gnu-tar autoconf automake cmake coreutils libtool swig wget xz python3
  • Ensure that the newly installed bash is set to override the default in your PATH.

8. Running the Build Script

Run the SDK build command:

./build.sh all

If you need to clean previous configurations, use:

./build.sh clean

9. Download Required Files

Download files from this link, uncompress them, and place the debug and release folders in app/src.

10. Disable Pre-built SDK

Make necessary changes in buildUtil.kt and settings.gradle.kts as instructed to disable pre-built SDK.

11. Build Mobile Analytics Library Locally

  • Clone the mobile analytics code and build it as follows:
  • git clone --recursive https://github.com/meganz/mobile-analytics.git
    cd mobile-analytics
    git checkout main
    ./gradlew assembleRelease

12. Disable Library Dependencies

Comment out specified codes in build.gradle.kts and settings.gradle.kts to disable unnecessary dependencies.

13. Running the Project

Open the project in Android Studio, allow it to build, and hit the ‘Run’ button.

Troubleshooting

If you face an issue where CMake is not detected while building the ffmpeg extension on macOS, here’s what to do:

  1. Open the SDK manager in Android Studio.
  2. Check “Show package details” and select CMake version 3.22.
  3. Update your PATH accordingly.
  4. Retry the build.

If you encounter any other issues, such as licenses not being accepted, use the sdkmanager command-line tool to address this:

path-to-cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME --licenses

If you need further assistance, visit fxis.ai for insights, updates, or to collaborate on AI development projects.

Geolocation Feature

To enable the geolocation feature, obtain a Google Maps API key from this page. Replace the google_maps_key string in the specified XML files in your project.

Conclusion

Building the MEGA Android Client may seem intricate, but with the above guide, you can navigate through the complexities like a pro. At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox