Maps: Cannot read property 'StyleURL' of undefined

Created on 17 Sep 2019  路  7Comments  路  Source: react-native-mapbox-gl/maps

Describe the bug
After following the installation instructions, as soon as I load the app I get the following error: Cannot read property 'StyleURL' of undefined. It's caused by the following line during initialization: https://github.com/react-native-mapbox-gl/maps/blob/master/javascript/components/MapView.js#L23. It appears the NativeModule MGLModule is not loaded despite the fact that I added RCTMGLPackage to the packages list in MainApplication.java (and other gradle files).

To Reproduce
Install, import maps, run the app with Expo.

Expected behavior
App loads without crashing.

Screenshots
Screenshot_2019-09-17-13-15-57-611_host exp exponent

Versions

  • Platfrom: Android
  • Device: Xiomi Redmi 6
  • OS: Android 8.1.0
  • SDK Version: 28
  • React Native Version: 0.59.10

All 7 comments

My MainApplication.java:

package com.myapp;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.sociochat.generated.BasePackageList;
import com.swmansion.reanimated.ReanimatedPackage;
import com.swmansion.rnscreens.RNScreensPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;

import org.unimodules.adapters.react.ReactAdapterPackage;
import org.unimodules.adapters.react.ModuleRegistryAdapter;
import org.unimodules.adapters.react.ReactModuleRegistryProvider;
import org.unimodules.core.interfaces.Package;
import org.unimodules.core.interfaces.SingletonModule;
import expo.modules.constants.ConstantsPackage;
import expo.modules.permissions.PermissionsPackage;
import expo.modules.filesystem.FileSystemPackage;
import com.mapbox.rctmgl.RCTMGLPackage;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {
  private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(
    new BasePackageList().getPackageList(),
    Arrays.<SingletonModule>asList()
  );

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new RCTMGLPackage(),
          new ReactNativeConfigPackage(),
          new ReanimatedPackage(),
          new RNGestureHandlerPackage(),
          new RNScreensPackage(),
          new ModuleRegistryAdapter(mModuleRegistryProvider)
      );
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}

Is this a properly detached expo? If so, are other packages with native modules installed properly?

@kristfal I didn't detach Expo. Should I? Where is this documented? I haven't tested other native modules. I haven't used React Native for a while so there might be things I'm missing

Where does it say we can't run in expo?

Expo is not supported as this library requires native code changes. You鈥檒l need to eject.

If this was documented it would have saved having to dig

If this was documented it would have saved having to dig

it is kinda: https://github.com/react-native-mapbox-gl/maps#expo-support

Was this page helpful?
0 / 5 - 0 ratings

Related issues

peterleng picture peterleng  路  4Comments

gmaclennan picture gmaclennan  路  3Comments

andrei-tofan picture andrei-tofan  路  5Comments

magnusburton picture magnusburton  路  3Comments

ivari picture ivari  路  3Comments