android_setup

guoling edited this page Sep 19, 2018 · 2 revisions

MMKV for Android

MMKV is an efficient, samll, easy-to-use mobile key-value storage framework used in the WeChat application. It's currently available on iOS and Android.

Getting Started

Prerequisites

  • API level 16 and above are supported.
  • NDK r16b and below (should you choose to build MMKV from source)

Installation

  • Via Maven

    1. Add the following lines to build.gradle on your app module:

      dependencies {
          implementation 'com.tencent:mmkv:1.0.10'
          // replace "1.0.10" with any available version
      }

      This will cause Gradle to download AAR package while building your application.

  • Via Prebuilt AAR Package

    1. Download AAR package from release page;

    2. Import the AAR as new module. In Android Studio, select File -> New -> New Module... menu and choose "Import JAR/AAR Package";

    3. Add a dependency on the new module. This can be done using File -> Project Structure... in Android Studio, or by adding following code to application's build.gradle:

      dependencies {
          implementation project(':mmkv')
      }
  • Build from Source

    1. Getting source code from git repository:

      git clone https://github.com/Tencent/MMKV.git
      cd mmkv
      
    2. Install Android NDK r16b. If Gradle failed to find your SDK and/or NDK, you may need to create a file named local.properties on the Android/MMKV/ directory with content:

      sdk.dir=path/to/sdk
      ndk.dir=path/to/ndk
      

      note: Starting from NDK r17, ARMv5 (armeabi) is not supported. You can use the latest NDK if your app doesn't need to support that architecture, by deleting this line in Android/MMKV/mmkv/build.gradle:

      abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
    3. Open Android/MMKV project in Android Studio and start building, or you can do it in terminal:

      cd Android/MMKV
      ./gradlew build
      

What's next

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.