Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expo SDK 52 Development build does not work on Android #781

Closed
codan84 opened this issue Dec 11, 2024 · 6 comments
Closed

Expo SDK 52 Development build does not work on Android #781

codan84 opened this issue Dec 11, 2024 · 6 comments

Comments

@codan84
Copy link

codan84 commented Dec 11, 2024

I have latest Expo development build with "newArchEnabled": true.
react-native-mmkv 3.1.0
react-native 0.76.2

Code:

const storage = new MMKV({ id: 'auth', encryptionKey: 'foo-bar' })

Works on iOS development build alright. But on Android:

 (NOBRIDGE) ERROR  Warning: Error: Failed to create a new MMKV instance: The native MMKV Module could not be found.
* Make sure react-native-mmkv is correctly autolinked (run `npx react-native config` to verify)
* Make sure you enabled the new architecture (TurboModules) and CodeGen properly generated the react-native-mmkv specs. See https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-apps.md
* Make sure you are using react-native 0.74.0 or higher, because react-native-mmkv is a C++ TurboModule.
* Make sure you rebuilt the app.
* Make sure gradle is synced. 
    at ContextNavigator (http://192.168.4.133:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&hot=false&transform.engine=hermes&transform.bytecode=1&transform.routerRoot=app&unstable_transformProfile=hermes-stable:154170:24)
    at ExpoRoot (http://192.168.4.133:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&hot=false&transform.engine=hermes&transform.bytecode=1&transform.routerRoot=app&unstable_transformProfile=hermes-stable:154119:28)
    at App
    at ErrorToastContainer (http://192.168.4.133:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&hot=false&transform.engine=hermes&transform.bytecode=1&transform.routerRoot=app&unstable_transformProfile=hermes-stable:236721:24)
    at ErrorOverlay
    at withDevTools(ErrorOverlay) (http://192.168.4.133:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&hot=false&transform.engine=hermes&transform.bytecode=1&transform.routerRoot=app&unstable_transformProfile=hermes-stable:116819:27)
    at RCTView
    at View (http://192.168.4.133:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&hot=false&transform.engine=hermes&transform.bytecode=1&transform.routerRoot=app&unstable_transformProfile=hermes-stable:38161:43)
    at RCTView
    at View (http://192.168.4.133:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&hot=false&transform.engine=hermes&transform.bytecode=1&transform.routerRoot=app&unstable_transformProfile=hermes-stable:38161:43)
    at AppContainer (http://192.168.4.133:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&hot=false&transform.engine=hermes&transform.bytecode=1&transform.routerRoot=app&unstable_transformProfile=hermes-stable:38033:25)
    at main(RootComponent) (http://192.168.4.133:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&hot=false&transform.engine=hermes&transform.bytecode=1&transform.routerRoot=app&unstable_transformProfile=hermes-stable:106272:28)

Output of react-native config:

//***//
    "react-native-mmkv": {
      "root": "/Users/dang/workspace/priv/orderly-client-mobile/node_modules/react-native-mmkv",
      "name": "react-native-mmkv",
      "platforms": {
        "ios": {
          "podspecPath": "/Users/dang/workspace/priv/orderly-client-mobile/node_modules/react-native-mmkv/react-native-mmkv.podspec",
          "version": "3.1.0",
          "configurations": [],
          "scriptPhases": []
        },
        "android": {
          "sourceDir": "/Users/dang/workspace/priv/orderly-client-mobile/node_modules/react-native-mmkv/android",
          "packageImportPath": "import com.mrousavy.mmkv.MmkvPackage;",
          "packageInstance": "new MmkvPackage()",
          "buildTypes": [],
          "libraryName": "RNMmkvSpec",
          "componentDescriptors": [],
          "cmakeListsPath": "/Users/dang/workspace/priv/orderly-client-mobile/node_modules/react-native-mmkv/android/build/generated/source/codegen/jni/CMakeLists.txt",
          "cxxModuleCMakeListsModuleName": "react-native-mmkv",
          "cxxModuleCMakeListsPath": "/Users/dang/workspace/priv/orderly-client-mobile/node_modules/react-native-mmkv/android/CMakeLists.txt",
          "cxxModuleHeaderName": "NativeMmkvModule",
          "isPureCxxDependency": false
        }
      }
    },
//***//

Some gradlew logs:

> 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

> Task :react-native-mmkv:generateCodegenSchemaFromJavaScript
> Task :react-native-mmkv:generateCodegenArtifactsFromSchema

> Task :react-native-mmkv:preBuild
> Task :react-native-mmkv:preDebugBuild

> Task :react-native-mmkv:writeDebugAarMetadata
> Task :react-native-mmkv:generateDebugResValues
> Task :react-native-mmkv:generateDebugResources
> Task :react-native-mmkv:packageDebugResources

> Task :react-native-mmkv:extractDeepLinksDebug
> Task :react-native-mmkv:processDebugManifest
> Task :react-native-mmkv:compileDebugLibraryResources
> Task :react-native-mmkv:parseDebugLocalResources
> Task :react-native-mmkv:generateDebugRFile
> Task :react-native-mmkv:generateDebugBuildConfig
> Task :react-native-mmkv:javaPreCompileDebug
> Task :react-native-mmkv:compileDebugJavaWithJavac
> Task :react-native-mmkv:bundleLibCompileToJarDebug

Note: /home/expo/workingdir/build/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.

> Task :react-native-mmkv:mergeDebugShaders
> Task :react-native-mmkv:compileDebugShaders NO-SOURCE
> Task :react-native-mmkv:generateDebugAssets UP-TO-DATE
> Task :react-native-mmkv:packageDebugAssets

> Task :react-native-mmkv:bundleLibRuntimeToJarDebug
> Task :react-native-mmkv:processDebugJavaRes NO-SOURCE

> Task :react-native-mmkv:mergeDebugJniLibFolders
> Task :react-native-mmkv:mergeDebugNativeLibs NO-SOURCE
> Task :react-native-mmkv:copyDebugJniLibsProjectOnly

Android model/version: OnePlus 5, Android 10.
Gradle 8.10.2
Any idea what might be going wrong?

Copy link

Guten Tag, Hans here!

It looks like you're having trouble with the MMKV instance on Android. 😅 You provided quite a lot of info, but I think it would be helpful to check if the native module is properly linked and if some steps were missed when enabling TurboModules.

Please ensure you run npx react-native config and check if the output is correct. Also, verify that you've followed all the steps in the documentation to enable the new architecture correctly.

If you continue to have issues, please provide logs from adb logcat, as that would help mrousavy diagnose the problem better. Remember, if you enjoy using this project, consider sponsoring to help keep it maintained! 🍻

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

@sebbalex
Copy link

same here, @mrousavy please, could you have a look

@codan84
Copy link
Author

codan84 commented Dec 12, 2024

Funny enough it works on an emulator just fine 🤷

@codan84
Copy link
Author

codan84 commented Dec 12, 2024

Ok I did more digging around and I reckon this is not an issue with this lib but with Expo itself (@sebbalex @mrousavy).
I had similar issue with google-login library.
The app actually works on Android ok if you connect your installed Expo Development build to your locally running server in a specific way, and fails otherwise.
Fails:

  1. Open your app on Android device
  2. Login to your expo account
  3. Connect to the server fetched after login

This will fail every time with the error above, no exceptions!

To make it work:

  1. Open your app on Android device
  2. DO NOT login to your expo account!
  3. Click Enter URL manually
  4. Type in IP of your locally running server
  5. Click Connect

This MAY fail with the same error the forst time you do it, but any subsequent attempts will start the app alright.
I will post my findings on Expo Discord.

@mrousavy
Copy link
Owner

Duplicate of #776. Yes, this is not caused by react-native-mmkv - please stop pinging me

@uguraktas
Copy link

@mrousavy both tickets are closed but there is no solution. You can at least let people discuss and find solutions, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants