无法为反应原生应用集成反应原生地图



我是React-Native的新手,当我尝试将React-Native-Maps与我的React Native App集成时,它给出了以下错误。

FAILURE: Build failed with an exception.
* Where:
Settings file 'D:React-ProjectsNativeReactNativeMapsandroidsettings.gradle' line: 3
* What went wrong:
Could not compile settings file 'D:React-ProjectsNativeReactNativeMapsandroidsettings.gradle'.
> startup failed:
  settings file 'D:React-ProjectsNativeReactNativeMapsandroidsettings.gradle': 3: unexpected char: '' @ line 3, column 111.
       node_modulesreact-native-mapslibandro
                               ^

1错误

这是我的build.gradle依赖项数组。

dependencies {
    implementation project(':react-native-maps'){
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    implementation 'com.google.android.gms:play-services-base:12.0.0'
    implementation 'com.google.android.gms:play-services-maps:12.0.0'
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
}

这是我的settings.gradle文件内容。

rootProject.name = 'ReactNativeMaps'
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '..node_modulesreact-native-mapslibandroid')
include ':app'

如果有人需要查看完整错误,

$ react-native run-android
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
FAILURE: Build failed with an exception.
* Where:
Settings file 'D:React-ProjectsNativeReactNativeMapsandroidsettings.gradle' line: 3
* What went wrong:
Could not compile settings file 'D:React-ProjectsNativeReactNativeMapsandroidsettings.gradle'.
> startup failed:
  settings file 'D:React-ProjectsNativeReactNativeMapsandroidsettings.gradle': 3: unexpected char: '' @ line 3, column 111.
     node_modulesreact-native-mapslibandro
                                   ^
  1 error

* 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
Could not install the app on the device, read 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
Command failed: gradlew.bat installDebug
Error: Command failed: gradlew.bat installDebug
    at checkExecSyncError (child_process.js:616:11)
    at Object.execFileSync (child_process.js:634:13)
    at runOnAllDevices (D:React-ProjectsNativeReactNativeMapsnode_modulesreact-nativelocal-clirunAndroidrunAndroid.js:299:19)
    at buildAndRun (D:React-ProjectsNativeReactNativeMapsnode_modulesreact-nativelocal-clirunAndroidrunAndroid.js:135:12)
    at isPackagerRunning.then.result (D:React-ProjectsNativeReactNativeMapsnode_modulesreact-nativelocal-clirunAndroidrunAndroid.js:65:12)
    at process._tickCallback (internal/process/next_tick.js:68:7)

我也通过以下命令安装了反应型映射,也将其链接。

npm install --save react-native-maps
react-native link react-native-maps

这是package.json文件。

{
  "name": "ReactNativeMaps",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.6.3",
    "react-native": "0.58.4",
    "react-native-maps": "^0.23.0"
  },
  "devDependencies": {
    "babel-core": "7.0.0-bridge.0",
    "babel-jest": "24.1.0",
    "jest": "24.1.0",
    "metro-react-native-babel-preset": "0.51.1",
    "react-test-renderer": "16.6.3"
  },
  "jest": {
    "preset": "react-native"
  }
}

出了什么问题?我错过了什么吗?

在您的包装中。

"react-native-maps": "https://github.com/react-community/react-native-maps.git"

settings.gradle中,请确保您的第3行是:

project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')

检查是否有效。

我发现了问题。构建是api_key的原因。我用新的API密钥替换API-KEY及其现在工作。以及更改线

project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')

相关内容

  • 没有找到相关文章

最新更新