react-native-maps: Execution failed for task ':react-native-maps:compileReleaseJavaWithJavac'.

Summary

hi I am having an issue. i am using react-native 0.72.3 library is compiling fine when building locally. but when i build for production, i get the following error:

Task :react-native-maps:compileReleaseJavaWithJavac FAILED /Users/vagrant/git/node_modules/react-native-maps/android/src/main/java/com/rnmaps/maps/MapUIBlock.java:7: error: cannot find symbol import com.facebook.react.fabric.interop.UIBlockViewResolver; ^ symbol: class UIBlockViewResolver location: package com.facebook.react.fabric.interop /Users/vagrant/git/node_modules/react-native-maps/android/src/main/java/com/rnmaps/maps/MapUIBlock.java:64: error: cannot find symbol interface UIBlockInterface extends UIBlock, com.facebook.react.fabric.interop.UIBlock {} ^ symbol: class UIBlock location: package com.facebook.react.fabric.interop /Users/vagrant/git/node_modules/react-native-maps/android/src/main/java/com/rnmaps/maps/MapUIBlock.java:35: error: cannot find symbol public void execute(UIBlockViewResolver uiBlockViewResolver) { ^ symbol: class UIBlockViewResolver location: class MapUIBlock /Users/vagrant/git/node_modules/react-native-maps/android/src/main/java/com/rnmaps/maps/MapUIBlock.java:39: error: cannot find symbol private void executeImpl(NativeViewHierarchyManager nvhm, UIBlockViewResolver uiBlockViewResolver) { ^ symbol: class UIBlockViewResolver location: class MapUIBlock /Users/vagrant/git/node_modules/react-native-maps/android/src/main/java/com/rnmaps/maps/MapUIBlock.java:56: error: cannot find symbol ((FabricUIManager) uiManager).addUIBlock(this); ^ symbol: method addUIBlock(MapUIBlock) location: class FabricUIManager Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 5 errors FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:react-native-maps:compileReleaseJavaWithJavac’.

Compilation failed; see the compiler error output for details.

  • Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

i tried version .4 to today’s .6. still same error. any help will be appreciated.thanks

Reproducible sample code

<MapView
              style={styles.map}
              //specify our coordinates.
              region={{
                latitude: latitude,
                longitude: longitude,
                latitudeDelta: 0.0005,
                longitudeDelta: 0.0005,
              }}
            >
              {/*Make sure the Marker component is a child of MapView. Otherwise it won't render*/}
              <Marker
                coordinate={{
                  latitude: latitude,
                  longitude: longitude,
                }}
                pinColor={COLORS.BLUE}
                onPress={() => {
                  showLocation({
                    latitude: latitude,
                    longitude: longitude,
                  });
                }}
              />
            </MapView>

Steps to reproduce

honestly i don’t know what specific steps, do i need to follow. i am just using bitrise to build and getting this error.

Expected result

suppose to compile the code without error

Actual result

compiling getting failed with error.

React Native Maps Version

1.15.4, 1.15.6

What platforms are you seeing the problem on?

Android

React Native Version

0.72.3

What version of Expo are you using?

Not using Expo

Device(s)

pixel 4

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 7
  • Comments: 50

Most upvoted comments

Remove the ^ mark from the package.json and don’t use the latest version.

“react-native-maps”: “1.15.3”,

for this version you will find it to be stable for android.

i have removed ^ sign from version and its works “react-native-maps”: “1.15.3”, thank you @cindyfelicia

try using 1.11.3. I was using this and it’s working well.

Everyone please don’t use the latest version of the library without the latest react-native.

There is often breaking changes, v1.13.2 and previous should be used if you’re not using react-native 0.74

Getting some errors on the MapUIBlock.java

Screenshot 2024-05-31 at 10 45 36 AM

The issue you’re facing occurs because react-native-maps requires additional configuration when building for a production APK. It works fine in the development environment (local), but for the APK, you need to configure the Google Maps SDK for Android. Here’s a detailed breakdown of the steps you need to follow:

1. Register a Google Cloud API Project

  • Go to the Google Cloud Console.
  • Create a new project or use an existing one.
  • Enable the Maps SDK for Android by navigating to APIs & Services > Library, searching for Maps SDK for Android, and enabling it.

2. Create an API Key

  • In the Google Cloud Console, go to APIs & Services > Credentials.
  • Click on Create Credentials and select API Key.
  • Initially, do not restrict the API key (you can restrict it later if needed).
  • Copy the API key that is generated.

3. Add the API Key to Your Project

  • In your app.json (or app.config.js) file, add the API key in the appropriate section for Android:
    "android": {
      "config": {
        "googleMaps": {
          "apiKey": "YOUR_GOOGLE_MAPS_API_KEY"
        }
      }
    }
    
  • Replace "YOUR_GOOGLE_MAPS_API_KEY" with the actual API key you generated.

4. Update react-native-maps to Use Google Maps

  • In your code, ensure you import the PROVIDER_GOOGLE from react-native-maps and pass it to the MapView component:
    import MapView, { PROVIDER_GOOGLE } from 'react-native-maps';
    
    <MapView
      provider={PROVIDER_GOOGLE}
      style={{ flex: 1 }}
      region={mapRegion}
    >
      <Marker coordinate={mapRegion} />
    </MapView>
    

5. Rebuild Your APK

  • After adding the API key and making the necessary configurations, rebuild your APK.
  • If you’re using Expo, make sure you’re using the appropriate build configuration, such as EAS Build.
  • For bare React Native projects, run the following command to build your APK:
    npx react-native run-android --variant=release
    

6. Test the APK

  • Once the APK is built and installed on a physical device, test the app to ensure the map is loading correctly.
  • If everything works fine, you can now choose to restrict the API key for additional security.

7. Restrict the API Key (Optional but Recommended)

  • If you want to restrict the API key later for security reasons, go back to Google Cloud Console > APIs & Services > Credentials.
  • Click on your API key and under Key restrictions, choose Android apps.
  • Add your package name (e.g., com.yourapp.name) and the SHA-1 certificate (if you plan to restrict it to a specific certificate).
    • To get the SHA-1 certificate for development builds, run:
      keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
      
    • For Google Play Store builds, retrieve the SHA-1 from the App Integrity section in the Google Play Console.

8. Rebuild and Test Again

  • After restricting the API key, rebuild your APK and test again to ensure everything is working correctly with the restricted API key.

By following these steps, you can successfully configure Google Maps for your React Native app without restricting the API key initially, and later add the restrictions for security if needed.

1.15.4 works too, which is good, since it includes a fix for an issue which will soon block iOS App Store uploads.

We’ll soon need at least 1.15.6 due to the privacy issue on iOS: https://github.com/react-native-maps/react-native-maps/pull/5078

try using 1.11.3. I was using this and it’s working well.

i can confirm that i was able to build using 1.15.3. thank you for the help @kumVineet .

same issue using react native 0.73.0

I am using "react-native": "0.73.2" with "react-native-maps": "1.14.0" removed ^ . it works

I have same issue with react native 0.73.8, even i have tried 1.15.3 but still i am getting same error

react-native: 0.73.6 react-native-maps: 1.15.4 worked for me for both platforms (previously react-native-maps: 1.20.0 was working only for iOS i downgraded to 1.15.4 and it worked for both)

try using 1.11.3. I was using this and it’s working well.

It worked for me

@salah-ghanim not sure why this was close, a patch release has broken support, 1.15.3 works, 1.15.4 doesn’t. This is a true bug. Backward compatability should not be broken in a patch version release.

i have removed ^ sign from version and its works “react-native-maps”: “1.15.3”, thank you @cindyfelicia

Yes this will also worked for me Thankyou

I have same issue with react native 0.73.8, even i have tried 1.15.3 but still i am getting same error

yes i use react native 0.73.8 and map 1.15.3 , 1.15.4, but still iam getting same error. how iis it slove

Try 1.13.2

Looking at changelog, 1.15.4 should be ok. I tried and it works.