react-native-mmkv icon indicating copy to clipboard operation
react-native-mmkv copied to clipboard

Erro build in Expo SDK 52 and MMKV 3.2.0

Open danieljuniorce opened this issue 10 months ago • 16 comments

Hey, I'm trying to build with npx expo run:android I'm getting this specific error from mmkv.

Expo: 52.0.28 react-native-mmkv: 3.2.0 JDK: 17

> Configure project :react-native-mmkv
[react-native-mmkv] Thank you for using react-native-mmkv ❤️
[react-native-mmkv] If you enjoy using react-native-mmkv, please consider sponsoring this project: https://github.com/sponsors/mrousavy

> Configure project :react-native-reanimated
Android gradle plugin: 8.6.0
Gradle: 8.10.2

> Task :app:processDebugMainManifest
/home/danieljuniorce/develop/fluke/whitelabel-app/android/app/src/debug/AndroidManifest.xml:6:5-162 Warning:
        application@android:usesCleartextTraffic was tagged at AndroidManifest.xml:6 to replace other declarations but no other declaration present
/home/danieljuniorce/develop/fluke/whitelabel-app/android/app/src/debug/AndroidManifest.xml Warning:
        provider#expo.modules.filesystem.FileSystemFileProvider@android:authorities was tagged at AndroidManifest.xml:0 to replace other declarations but no other declaration present

> Task :react-native-mmkv:compileDebugJavaWithJavac FAILED
/home/danieljuniorce/develop/fluke/whitelabel-app/node_modules/react-native-mmkv/android/src/main/java/com/mrousavy/mmkv/MmkvPlatformContextModule.java:7: error: cannot find symbol
public class MmkvPlatformContextModule extends NativeMmkvPlatformContextSpec {
                                               ^
  symbol: class NativeMmkvPlatformContextSpec
/home/danieljuniorce/develop/fluke/whitelabel-app/node_modules/react-native-mmkv/android/src/main/java/com/mrousavy/mmkv/MmkvPlatformContextModule.java:15: error: method does not override or implement a method from a supertype
    @Override
    ^
/home/danieljuniorce/develop/fluke/whitelabel-app/node_modules/react-native-mmkv/android/src/main/java/com/mrousavy/mmkv/MmkvPlatformContextModule.java:21: error: method does not override or implement a method from a supertype
    @Override
    ^
/home/danieljuniorce/develop/fluke/whitelabel-app/node_modules/react-native-mmkv/android/src/main/java/com/mrousavy/mmkv/MmkvPackage.java:19: error: cannot find symbol
    if (name.equals(MmkvPlatformContextModule.NAME)) {
                                             ^
  symbol:   variable NAME
  location: class MmkvPlatformContextModule
/home/danieljuniorce/develop/fluke/whitelabel-app/node_modules/react-native-mmkv/android/src/main/java/com/mrousavy/mmkv/MmkvPackage.java:20: error: incompatible types: MmkvPlatformContextModule cannot be converted to NativeModule
      return new MmkvPlatformContextModule(reactContext);
             ^
/home/danieljuniorce/develop/fluke/whitelabel-app/node_modules/react-native-mmkv/android/src/main/java/com/mrousavy/mmkv/MmkvPackage.java:31: error: cannot find symbol
              MmkvPlatformContextModule.NAME,
                                       ^
  symbol:   variable NAME
  location: class MmkvPlatformContextModule
/home/danieljuniorce/develop/fluke/whitelabel-app/node_modules/react-native-mmkv/android/src/main/java/com/mrousavy/mmkv/MmkvPackage.java:33: error: cannot find symbol
                      MmkvPlatformContextModule.NAME,
                                               ^
  symbol:   variable NAME
  location: class MmkvPlatformContextModule
/home/danieljuniorce/develop/fluke/whitelabel-app/node_modules/react-native-mmkv/android/src/main/java/com/mrousavy/mmkv/MmkvPackage.java:34: error: cannot find symbol
                      MmkvPlatformContextModule.NAME,
                                               ^
  symbol:   variable NAME
  location: class MmkvPlatformContextModule
Note: /home/danieljuniorce/develop/fluke/whitelabel-app/node_modules/react-native-mmkv/android/src/main/java/com/mrousavy/mmkv/MmkvPackage.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
8 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-mmkv:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
> Run with --info option to get more log output.
> Run with --scan to get full insights.

danieljuniorce avatar Feb 01 '25 15:02 danieljuniorce

Guten Tag, Hans here. Thanks for ze detailed report, but it seems like you're missing some relevant logs from your build process. We need to see more output to understand ze issue properly. Please include those logs and check ze documentation for guidance on using react-native-mmkv. Also, if you appreciate mrousavy's time and effort, considering sponsoring ze project here. 🥨

Note: If you think I made a mistake by closing this issue, please ping @mrousavy to take a look.

maintenance-hans[bot] avatar Feb 01 '25 15:02 maintenance-hans[bot]

hmm, are you using new arch?

mrousavy avatar Feb 03 '25 09:02 mrousavy

@danieljuniorce resolved by

app.json

  "expo": {
    // ...
    "plugins": [
      [
        "expo-build-properties",
        {
          "ios": {
            "newArchEnabled": true
          },
          "android": {
            "newArchEnabled": true
          }
        }
      ]
    ]
  }
}

enavermate avatar Feb 05 '25 14:02 enavermate

@enavermate are you using sdk 52? the API you should is for sdk 51 and below https://docs.expo.dev/guides/new-architecture/#enable-the-new-architecture-in-an-existing-project

i've encountered the same issue and want to try and migrate back to mmkv v3

gabimoncha avatar Feb 12 '25 16:02 gabimoncha

@gabimoncha yes Image

I've used last suggested by Expo package versions throw npx expo install --check Image

enavermate avatar Feb 12 '25 19:02 enavermate

cool. will give it a try then

gabimoncha avatar Feb 16 '25 19:02 gabimoncha

I'm encountering the same issue with

    expo: 52.0.35
    react-native: 0.76.7

app.json

"expo": {
    ....
    "newArchEnabled": true,
    ....
}

haivle avatar Feb 17 '25 12:02 haivle

Same issue, any suggestion expo version : 52.0.37

mimo-10 avatar Mar 09 '25 14:03 mimo-10

@danieljuniorce resolved by

app.json

  "expo": {
    // ...
    "plugins": [
      [
        "expo-build-properties",
        {
          "ios": {
            "newArchEnabled": true
          },
          "android": {
            "newArchEnabled": true
          }
        }
      ]
    ]
  }
}

it worked . i installed expo-build-properties and then added the plugin config as shown here.

mimo-10 avatar Mar 10 '25 03:03 mimo-10

I have the same problem, any ideas on how to fix it?

expo: 52.0.35
react-native: 0.76.7

redbluenat avatar Mar 18 '25 10:03 redbluenat

@mrousavy is it possible that turbomodules is enabled only through expo-build-properties "newArchEnabled"

it seems that turbomodules is disabled either way, and has to be manually enabled in app.json

experiments: {
  turboModules: true
}

https://github.com/expo/expo/blob/bcd6ce42add44554d45cf1c060799ea64b646701/packages/%40expo/config-types/src/ExpoConfig.ts#L274

gabimoncha avatar Mar 19 '25 18:03 gabimoncha

I guess - I don't use Expo. Bare RN has new arch enabled by default for a long time now, not sure about Expo.

mrousavy avatar Mar 20 '25 03:03 mrousavy

We have bare RN with expo dependencies and I fixed the same error by setting

newArchEnabled=true in gradle.properties file

Greeeeyyyss avatar Mar 21 '25 10:03 Greeeeyyyss

Using SDK 53 Image

SohelIslamImran avatar May 08 '25 18:05 SohelIslamImran

I didn't have any issues with MMKV since updating to Expo 53.

@SohelIslamImran can you try this config in app.json

...
experiments: {
	turboModules: true
},
...

gabimoncha avatar May 09 '25 10:05 gabimoncha

Using SDK 53 Image

I think I know what's going on.

react-native-mmkv DOES NOT support Expo Go.

You have to make a development build by Expo.

Specificlly, you need to run following commands in your project root

npx expo install expo-dev-client
npx expo run:android

philwu avatar Jun 02 '25 08:06 philwu

I think this has been fixed in react-native-mmkv 4.x.x-beta.

You need to be on new architecture. Clean your cache and rebuild the native project.

mrousavy avatar Aug 20 '25 14:08 mrousavy