运行android react本地地图生成失败

时间:2019-10-09 19:12:21

标签: ubuntu adb react-native-android react-native-maps

我正在尝试配置为在Android中运行一个react native项目,以启动节点js并准备运行我运行的“构建”

  

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

,然后在另一个终端中运行

  

react-native run-android

我的package.json:

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

出现第一个终端后,但出现以下错误:

    > 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

react-native-maps插件出现此错误还是识别设备的问题? (当我运行adb设备时,它会正确列出模拟器设备)

1 个答案:

答案 0 :(得分:1)

解决了! 当前版本的react-native-maps仅与0.60。+ react-native版本兼容。

我在package.json中更改了react-native-maps版本 来自

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

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