我正在尝试在我的项目中安装react-native-maps并遵循https://github.com/react-native-community/react-native-maps/blob/master/docs/installation.md中给出的说明。但是在Android中运行我的项目后仍然出现错误,它显示UIBlock的错误,它出现在Android Studio的react-native-maps的AirMapModule.java中。任何人都可以帮我这个吗?
以下是我的项目版本:
"react": "16.6.1",
"react-native": "^0.59.2",
"react-native-maps": "^0.23.0"
这是我得到的错误:
^
symbol: class UIBlock
location: package com.facebook.react.uimanager
D:\Maps\Project\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:129: error: getCurrentActivity() is not public in ReactContext; cannot be accessed from outside package
if (!contextHasBug(appContext.getCurrentActivity())) {
^
D:\Maps\Project\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:130: error: getCurrentActivity() is not public in ReactContext; cannot be accessed from outside package
superContext = appContext.getCurrentActivity();
^
D:\Maps\Project\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:133: error: cannot find symbol
if (!contextHasBug(reactContext.getCurrentActivity())) {
^
symbol: method getCurrentActivity()
location: variable reactContext of type ThemedReactContext
D:\Maps\Project\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:134: error: cannot find symbol
superContext = reactContext.getCurrentActivity();
^
symbol: method getCurrentActivity()
location: variable reactContext of type ThemedReactContext
D:\Maps\Project\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\ViewAttacherGroup.java:23: error: cannot find symbol
this.setOverflow("hidden"); // Change to ViewProps.HIDDEN until RN 0.57 is base
^
symbol: method setOverflow(String)
D:\Maps\Project\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapMarkerManager.java:127: error: method does not override or implement a method from a supertype
@Override
^
D:\Maps\Project\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapMarkerManager.java:130: error: cannot find symbol
super.setZIndex(view, zIndex);
^
symbol: method setZIndex(AirMapMarker,float)
D:\Maps\Project\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapModule.java:90: error: cannot find symbol
uiManager.addUIBlock(new UIBlock() {
^
symbol: class UIBlock
location: class AirMapModule
D:\Maps\Project\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapModule.java:149: error: cannot find symbol
uiManager.addUIBlock(new UIBlock()
^
symbol: class UIBlock
location: class AirMapModule
D:\Maps\Project\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapModule.java:192: error: cannot find symbol
uiManager.addUIBlock(new UIBlock()
^
symbol: class UIBlock
location: class AirMapModule
D:\Maps\Project\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapModule.java:229: error: cannot find symbol
uiManager.addUIBlock(new UIBlock()
^
symbol: class UIBlock
location: class AirMapModule
D:\Maps\Project\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapModule.java:262: error: cannot find symbol
uiManager.addUIBlock(new UIBlock()
^
symbol: class UIBlock
location: class AirMapModule
D:\Maps\Project\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\RegionChangeEvent.java:15: error: no suitable constructor found for Event(int)
super(id);
^
constructor Event.Event() is not applicable
(actual and formal argument lists differ in length)
constructor Event.Event(int,long) is not applicable
(actual and formal argument lists differ in length)
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.
14 errors```
尝试拆分Maven依赖项,如下所述:
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url "https://maven.google.com"
}
}
}
https://github.com/react-native-community/react-native-maps/issues/2090