Search code examples
ubuntuadbreact-nativereact-native-maps

Run android react native maps failed on build


I'm trying to config to run in android a react native project, to start the node js and prepare to run the "build" i run

cd android && ./gradlew clean && cd .. && react-native start

and in another terminal I run the

react-native run-android

my package.json:

"react-native": "0.59.0",
"react-native-maps": "git://github.com/react-native-community/react-native-maps.git#master",

after first terminal appears done, but i'm getting the follow error:

    > Task :react-native-maps:compileDebugJavaWithJa
    vac FAILED
    warning: [options] source value 7 is obsolete and will be removed in a future release
    warning: [options] target value 7 is obsolete and will be removed in a future release
    warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
    /node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:12: error: package         androidx.core.view does not exist
    import androidx.core.view.GestureDetectorCompat;
                     ^
    /node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:13: error: package androidx.core.view does not exist
    import androidx.core.view.MotionEventCompat;
                     ^
   /node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:73: error: package androidx.core.content does not exist
    import static androidx.core.content.PermissionChecker.checkSelfPermission;
                               ^
    /node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:73: error: static            
    import only from classes and interfaces
    import static androidx.core.content.PermissionChecker.checkSelfPermission;
    ^
    /node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:108: error: cannot find symbol
      private final GestureDetectorCompat gestureDetector;
            ^
      symbol:   class GestureDetectorCompat
      location: class AirMapView
    /node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:165: error: cannot find symbol
            new GestureDetectorCompat(reactContext, new GestureDetector.SimpleOnGestureListener() {
        ^
      symbol:   class GestureDetectorCompat
      location: class AirMapView

    /node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:421: error: cannot find symbol
        return checkSelfPermission(getContext(), PERMISSIONS[0]) == PackageManager.PERMISSION_GRANTED ||
       ^
      symbol:   method checkSelfPermission(Context,String)
      location: class AirMapView
    /node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:422: error: cannot find symbol
            checkSelfPermission(getContext(), PERMISSIONS[1]) == PackageManager.PERMISSION_GRANTED;
    ^
      symbol:   method checkSelfPermission(Context,String)
      location: class AirMapView

    /node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java:949: error: cannot find symbol
        int action = MotionEventCompat.getActionMasked(ev);
                     ^
      symbol:   variable MotionEventCompat
      location: class AirMapView
    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.
    9 errors
    3 warnings

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':react-native-maps:compileDebugJavaWithJavac'.
    > 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.

    * Get more help at https://help.gradle.org

    BUILD FAILED in 1s
    186 actionable tasks: 1 executed, 185 up-to-date
    error Could not install the app on the device, r
    ead the error above for details.
    Make sure you have an Android emulator running or a device connected and have
    set up your Android development environment:
    https://facebook.github.io/react-native/docs/getting-started.html
    error Command failed: ./gradlew app:installDebug

Is this error with the react-native-maps plugin or problems to identify a device? (When i run adb devices, it lists correctly the emulator device)


Solution

  • Solved! The current version of react-native-maps is compatible only with 0.60.+ react-native versions.

    I changed the react-native-maps version in package.json from

    "react-native-maps": "git://github.com/react-native-community/react-native-maps.git#master",
    

    to

    "react-native-maps": "^0.25.0",