Describe the bug
When trying to launch the example app or my own project, the app crashes on startup to this, originating from MapView.js. My own project doesn't use Mapbox styles. For now I have to do all the developing on iOS which is working fine.
To Reproduce
Upgrade the example project to RN 0.60.5 and launch the app.
Expected behavior
Expected the app and the map to load.
Screenshots
https://imgur.com/a/Yaw0q8E
Versions (please complete the following information):
I'm getting the same issue in my project. I got iOS running great, but I'm getting this same Android issue. It looks like NativeModules.MGLModule is undefined on Android for me at this line.
And I'm using react-native-mapbox-gl/maps version 7.0.3
Sounds like the native code is not installed. Make sure you follow the
readme. I am not sure if autolinking works with this library.
On Wed, 4 Sep 2019 at 21:28, tsemerad notifications@github.com wrote:
And I'm using react-native-mapbox-gl/maps version 7.0.3
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/react-native-mapbox-gl/maps/issues/359?email_source=notifications&email_token=ABLAPWYOLNJFXL5QBV74JWDQIAD4ZA5CNFSM4ITEQVJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD54WFNA#issuecomment-528048820,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABLAPW2VSES3M44ZWALMV23QIAD4ZANCNFSM4ITEQVJA
.
You are correct, autolinking doesn't work for android side so following the readme fixes this problem. I was under the impression it did work, since I don't remember linking it to iOS.
I am getting the same issue in my expo app. can we use this package for expo?
You can't use this in expo because it uses native modules.
You can't use this in expo because it uses native modules.
What can I use to run my project instead of expo?
@EduardoDuX I think you just need to "eject" the Expo project. That will allow you to use native modules.
https://docs.expo.io/versions/latest/introduction/managed-vs-bare/#managed-workflow
In my case, the native module package is not added properly.
In the install example, it is needed to add the RCTMGLPackage in the override of getPackages function, but I have a ReactInstanceManager instance in MainActivity which added the package list when init.
In this case, it's needed to add RCTMGLPackage when init ReactInstanceManager.
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(this.getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModulePath("index")
.addPackage(new MainReactPackage())
.addPackage(new RCTMGLPackage())
.setCurrentActivity(this)
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
I have this problem too. I solved this with add import com.mapbox.rctmgl.RCTMGLPackage; and add packages.add(new RCTMGLPackage()); to getPackages() { } in MainApplication.java file. sorry about my bad language but it worked.
I'm getting the same issue in my project. I got iOS running great, but I'm getting this same Android issue. It looks like
NativeModules.MGLModuleis undefined on Android for me at this line.
- Device: Nexus 5X Simulator
- OS: Android 9.0
- SDK Version: 28
- React Native Version: 0.59.4
Most helpful comment
@EduardoDuX I think you just need to "eject" the Expo project. That will allow you to use native modules.
https://docs.expo.io/versions/latest/introduction/managed-vs-bare/#managed-workflow