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

Cannot build on Android React-native 0.80.0

Open FrancMihani opened this issue 6 months ago • 2 comments

Hello again, Sorry for not checking both platforms in the same time

Description: I am trying to build a new app with react-native-mmkv and it fails to build on Android.

Error Details: error: incompatible types: MmkvPlatformContextModule cannot be converted to NativeModule return new MmkvPlatformContextModule(reactContext); ^ /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 /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 /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 /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 /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 ^ /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 ^ /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 8 errors

Environment: react-native-mmkv version: 3.2 React Native version: 0.80.0 Platform: Android Architecture: New Architecture, Hermes

Context: The app wont build. The error as in the details. The project is brand new and there is no other modification on it.

FrancMihani avatar Jun 16 '25 11:06 FrancMihani

Guten Tag, Hans here! 🍻

I see you’re having trouble building your app on Android with react-native-mmkv. Thanks for providing detailed error logs and environment info!

To help narrow down ze issue, could you please check your Android SDK version and ensure it is updated? Also, make sure you have followed ze installation steps in ze documentation to set up everything properly. If ze problem persists, please try running a clean build or share your full build logs so we can diagnose better.

If you find this project helpful, consider sponsoring it at mrousavy's GitHub sponsors page to get ze best support!

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

maintenance-hans[bot] avatar Jun 16 '25 11:06 maintenance-hans[bot]

@mrousavy any update with this, or any workarounds ?

FrancMihani avatar Jul 02 '25 10:07 FrancMihani

No, no update. I haven't looked at this yet.

mrousavy avatar Jul 02 '25 10:07 mrousavy

I upgraded the app to 0.80.1 still the same problem, but something weird in android even why the newArchEnabled=true hermesEnabled=true , app runs using the Legacy Architecture. Even a fresh build runs in Legacy Architecture. Can this be the root of the problem?

FrancMihani avatar Jul 02 '25 14:07 FrancMihani

Same issue here. I can build the app using version 2.12.2, but when I run it, I get the error: 'Failed to create a new MMKV instance.'

ThiaAlves avatar Jul 08 '25 13:07 ThiaAlves

@ThiaAlves I created an issue in react-native repo https://github.com/facebook/react-native/issues/52375 this might be a problem with new arch not being enabled even though newArchEnabled=true

FrancMihani avatar Jul 08 '25 13:07 FrancMihani

I ran into the same issue, and in my case, the cause was a conflicting setting in my global Gradle properties.

💡 Solution: Check your ~/.gradle/gradle.properties file — I had the following line there:

newArchEnabled=false

This overrides the project-level setting and disables the new architecture even if it's enabled in your project’s gradle.properties.

✅ After removing or updating this value in the global config, the issue was resolved.

Hope this helps others who might be stuck on the same problem!

LJoel23 avatar Jul 16 '25 13:07 LJoel23

@LJoel23 thank you, yes this resolved the issue

FrancMihani avatar Jul 17 '25 11:07 FrancMihani