-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
android_setup
MMKV is an efficient, small, easy-to-use mobile key-value storage framework used in the WeChat application. It's currently available on both Android, iOS/macOS, Windows and POSIX.
- API level 23 and above are supported.
- NDK r16b and above (should you choose to build MMKV from source)
-
Via Maven
Starting from v1.2.8, MMKV has been migrated to Maven Central. Older versions (<= v1.2.7) are still available on JCenter.-
Add the following lines to
build.gradle
on your app module:dependencies { implementation 'com.tencent:mmkv:2.0.0' // replace "2.0.0" with any available version }
This will cause Gradle to download the AAR package while building your application.
-
By default, MMKV links libc++ with static library. The libc++ will consume about 2 MB size unpacked if shared linked. If you really care about bundle size and your project already includes
libc++_shared.so
by other JNI libs. You can use MMKV with shared linking of libc++, by adding this line to your Gradle:dependencies { implementation 'com.tencent:mmkv-shared:2.0.0' // replace "2.0.0" with any available version }
-
-
Build from Source
Starting from v1.2.9, MMKV no longer supports the armeabi arch officially. And armv7 is droped from (v1.3.5~v1.3.6) v2.0+, along with the API level been bumped to API level 23. If you need to support armeabi, armv7 or lower API level, you should build MMKV from the source.-
Getting source code from the git repository:
git clone https://github.com/Tencent/MMKV.git cd mmkv
-
Install the latest Android NDK from Android Studio's SDK Manager.
Note: Starting from NDK r17,ARMv5 (armeabi)
is no longer supported. If you need to support the armeabi arch, you should install NDK r16b instead, and uncomment these lines insideAndroid/MMKV/mmkv/build.gradle
:// uncomment this line to support armv7, add 'armeabi' to support armeabi // abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' ... // uncomment this line to support armeabi by using android-ndk-r16b // ndkVersion = '16.1.4479499'
If you need to support lower API level, change the root
build.gradle
'sminSdkVersion
variable:ext { minSdkVersion = 21 // change this to whatever you like .... }
-
Open
Android/MMKV
project in Android Studio, select the 'MMKV:mmkv [buildAndPublishToLocalMaven]' gradle task, click the Run button to start building. The resulting package should be found in your$HOME/.m2/repository/com/tencent/mmkv/$version
directory. You can add this to your App's build.gradle to verify that.repositories { mavenLocal() .... }
-
If you are pretty sure that encryption is not needed, you can turn on the preprocess directive
MMKV_DISABLE_CRYPT
inCore/MMKVPredef.h
to save some binary size. -
If you are pretty sure that MMKV for Flutter is not needed, you can turn on the preprocess directive
MMKV_DISABLE_FLUTTER
inCore/MMKVPredef.h
to save some binary size.
-
MMKV is published under the BSD 3-Clause license. For details check out the LICENSE.TXT.
Check out the CHANGELOG.md for details of change history.
If you are interested in contributing, check out the CONTRIBUTING.md, also join our Tencent OpenSource Plan.
To give clarity of what is expected of our members, MMKV has adopted the code of conduct defined by the Contributor Covenant, which is widely used. And we think it articulates our values well. For more, check out the Code of Conduct.
Check out the FAQ first. Should there be any questions, don't hesitate to create issues.
User privacy is taken very seriously: MMKV does not obtain, collect or upload any personal information. Please refer to the MMKV SDK Personal Information Protection Rules for details.
- In English
- 中文
- In English
- 中文
- In English
- 中文
-
In English
-
中文
-
Golang