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

Android: error: cannot find symbol MmkvModule.install #38

Closed
3DJakob opened this issue Mar 25, 2021 · 15 comments
Closed

Android: error: cannot find symbol MmkvModule.install #38

3DJakob opened this issue Mar 25, 2021 · 15 comments

Comments

@3DJakob
Copy link

3DJakob commented Mar 25, 2021

I installed this module and successfully used it on iOS. I then preceded with following the steps for setting up android with reanimated installed copying the code from the example. It could not find the module so I had to add it manually by adding

include ':react-native-mmkv'
project(':react-native-mmkv').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-mmkv/android/')

to settings.gradle and in build.gradle adding

implementation project(':react-native-mmkv')

As described here: #37

Strangely enough, it had added the code implementation 'com.tencent:mmkv-static:1.0.10' there from before but with that code it simply cannot load the module.

However when I try to build the project in android studio it fails with:

/Users/jakob/coding/my-app/android/app/src/main/java/com/striveapp/StriveJSIPackage.java:17: error: cannot find symbol
        MmkvModule.install(jsContext, reactApplicationContext.getFilesDir().getAbsolutePath() + "/mmkv");
                  ^
  symbol:   method install(JavaScriptContextHolder,String)
  location: class MmkvModule

Am I missing something here? Perhaps the module gets loaded incorrectly and thus cannot run the function? Just a noob with android development here, please tell me if you need some other information.

@mrousavy
Copy link
Owner

mrousavy commented Mar 25, 2021

Sorry I don't quite get the part with implementation 'com.tencent:mmkv-static:1.0.10' - where did that come from?

Does Android Studio underline the import com.reactnativemmkv.MmkvModule; line in StriveJSIPackage in red?

@3DJakob
Copy link
Author

3DJakob commented Mar 25, 2021

Hey! The 1.0.10 was in the file from the beginning so I replaced it with that other line. I guess it got there when it was trying to auto-link the dependency?

Yes android studio studio says "cannot resolve method 'install' in 'MmkvModule'

However, maybe the problem is before that. On this line public class StriveJSIPackage extends ReanimatedJSIModulePackage { it says cannot resolve symbol ReanimatedJSIModulePackage

The problem seems to be loading the Reanimated module 🤔

I have tried running yarn install react-native-reanimated, running version 2.0.1

Thank you for your time!

@mrousavy
Copy link
Owner

Could you share your versions? Reanimated, React Native, MMKV please

@3DJakob
Copy link
Author

3DJakob commented Mar 25, 2021

Sure!
react-native 0.63.2
react-native-reanimated 2.0.1
react-native-mmkv 1.0.10

Running android studio in rosetta on an M1 Mac could be related.

@mrousavy
Copy link
Owner

Hm, that's weird. Don't have an answer for this atm, I'll take a look when I have some free time

@mrousavy
Copy link
Owner

You could try to Cmd+Click the MmkvModule to find out if it actually exists as a class. Also try cleaning & rebuilding gradle

@3DJakob
Copy link
Author

3DJakob commented Mar 25, 2021

Weird indeed. Cmd+Clicking it takes me to the class. Tried cleaning and rebuilding without any luck.

@3DJakob
Copy link
Author

3DJakob commented Mar 25, 2021

Just to verify. This is the correct location for the JSIPackage right?
Screenshot 2021-03-25 at 19 52 43

I'm also going to start a fresh project to see if I can get it working there.

@mrousavy
Copy link
Owner

Yes it is the correct location - can you send a screenshot from android studio of the entire JSI package file you created?

@3DJakob
Copy link
Author

3DJakob commented Mar 25, 2021

I think I solved it! I made a new scratch project to try this in. At first, I had to do steps described in #37. Then I got error finding symbol JSIModulePackage. I then imported it like this in the mainApplication.java:

import com.facebook.react.bridge.JSIModulePackage;

That snippet is from the reanimated docks https://docs.swmansion.com/react-native-reanimated/docs/installation/. And then voila it compiled! Haven't actually tried using the module yet but seems promising. It looks however like I already tried that in the main repository that has reanimated already but I will do some troubleshooting over there to see if I can get it working there as well.

@3DJakob
Copy link
Author

3DJakob commented Mar 25, 2021

Here is the screenshot you asked for:

Edit: Realized that I had played around with adding line 1 package as well as type for the class but it does not effect the error.

Screenshot 2021-03-25 at 20 38 21

@3DJakob
Copy link
Author

3DJakob commented Mar 25, 2021

I think I solved it! I made a new scratch project to try this in. At first, I had to do steps described in #37. Then I got error finding symbol JSIModulePackage. I then imported it like this in the mainApplication.java:

import com.facebook.react.bridge.JSIModulePackage;

That snippet is from the reanimated docks https://docs.swmansion.com/react-native-reanimated/docs/installation/. And then voila it compiled! Haven't actually tried using the module yet but seems promising. It looks however like I already tried that in the main repository that has reanimated already but I will do some troubleshooting over there to see if I can get it working there as well.

This does not seem to be the issue in the main repository that uses the reanimated module, unfortunately.

@3DJakob
Copy link
Author

3DJakob commented Mar 25, 2021

So when I command+click the MmkvModule in my myAppNameJSIPackage.java I can't find any public function called install. Shouldn't there be one? I attached a screenshot with the file.
Screenshot 2021-03-25 at 22 00 38

@mrousavy
Copy link
Owner

mrousavy commented Mar 26, 2021

Oh jesus christ I just noticed you aren't on the latest MMKV version, you have to upgrade to 1.1.6!

@3DJakob
Copy link
Author

3DJakob commented Mar 26, 2021

Haha, I changed to the latest and it solved that problem! However, I'm getting other problems and I just cannot seem to get it to launch without crashing. However, since the problem described in this thread is resolved I will close this now. Thank you so much for your time and effort. Let's hope the android setup will be easier in the future!

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

2 participants