Skip to content

Commit

Permalink
[BUGFIX] Updated android and ios files for 0.75.x (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
dembeEdward authored Aug 19, 2024
1 parent 4d17859 commit fe4b06e
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 18 deletions.
6 changes: 6 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def reactNativeArchitectures() {
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

def isNewArchitectureEnabled() {
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

def USE_HERMES = rootProject.ext.hermesEnabled

repositories {
Expand All @@ -52,13 +56,15 @@ android {

buildFeatures {
prefab true
buildConfig true
}



defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 19)
targetSdkVersion safeExtGet('targetSdkVersion', 31)
buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
var appProject = rootProject.allprojects.find {it.plugins.hasPlugin('com.android.application')}
externalNativeBuild {
cmake {
Expand Down

This file was deleted.

47 changes: 46 additions & 1 deletion android/src/main/java/com/ammarahmed/mmkv/RNMMKVPackage.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,59 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.HashMap;

import androidx.annotation.Nullable;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.TurboReactPackage;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.module.model.ReactModuleInfo;
import com.facebook.react.module.model.ReactModuleInfoProvider;

public class RNMMKVPackage extends TurboReactPackage implements ReactPackage {

@Nullable
@Override
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
return new RNMMKVModule(reactContext);
}

@Override
public ReactModuleInfoProvider getReactModuleInfoProvider() {
Class<? extends NativeModule>[] moduleList = new Class[] {
RNMMKVModule.class
};

final Map<String, ReactModuleInfo> reactModuleInfoMap = new HashMap<>();
for (Class<? extends NativeModule> moduleClass : moduleList) {
ReactModule reactModule = moduleClass.getAnnotation(ReactModule.class);

reactModuleInfoMap.put(
reactModule.name(),
new ReactModuleInfo(
reactModule.name(),
moduleClass.getName(),
true,
reactModule.needsEagerInit(),
reactModule.hasConstants(),
reactModule.isCxxModule(),
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED));
}

return new ReactModuleInfoProvider() {
@Override
public Map<String, ReactModuleInfo> getReactModuleInfos() {
return reactModuleInfoMap;
}
};
}

public class RNMMKVPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Arrays.<NativeModule>asList(new RNMMKVModule(reactContext));
Expand Down
1 change: 0 additions & 1 deletion ios/MMKVNative.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#import <React/RCTBridge+Private.h>
#import <React/RCTUtils.h>
#import <ReactCommon/RCTTurboModule.h>


using namespace facebook;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-mmkv-storage",
"version": "0.10.2",
"version": "0.10.3",
"description": "This library aims to provide a fast & reliable solution for you data storage needs in react-native apps. It uses [MMKV](https://github.com/Tencent/MMKV) by Tencent under the hood on Android and iOS both that is used by their WeChat app(more than 1 Billion users). Unlike other storage solutions for React Native, this library lets you store any kind of data type, in any number of database instances, with or without encryption in a very fast and efficient way.",
"main": "./dist/index.js",
"scripts": {
Expand Down

0 comments on commit fe4b06e

Please sign in to comment.