项目名称“@mapbox/react-native-mapbox-gl”不得包含以下任何字符:[/、\​​、:、<、>、"、?、*、|]

The project name '@mapbox/react-native-mapbox-gl' must not contain any of the following characters: [/, \, :, <, >, ", ?, *, |]

我在 React Native 中使用 mapbox/react-native-mapbox-gl packpage,当 运行 在命令行中通过 React Native 应用程序时,我收到以下错误。

配置项目“:@mapbox/react-native-mapbox-gl”时出现问题。

The project name '@mapbox/react-native-mapbox-gl' must not contain any of the following characters: [/, \, :, <, >, ", ?, *, |]. Set the 'rootProject.name' or adjust the 'include' statement (see https://docs.gradle.org/5.0/dsl/org.gradle.api.initialization.Settings.html#org.gradle.api.initialization.Settings:include(java.lang.String[]) for more details).

我已经尝试删除项目名称中的@和/符号。

1 秒内构建失败 无法在设备上安装应用程序,请阅读上面的错误以了解详细信息。 确保您已连接 Android 模拟器 运行 或设备,并且 设置您的 Android 开发环境: https://facebook.github.io/react-native/docs/getting-started.html

首先,检查一下项目名和include不应该有重复项。 然后试试这个

更正依赖项中的包名称。

只需删除名称中的 [/, \, <, >, ", ?, *, |] 字符

  1. project-name/android/app/build.gradle

dependencies {
     compile project(':react-native-vector-icons')
    // here is the change just remove /, \, :, <, >, ", ?, *, | in the project parameter
    compile project(':mapbox-react-native-mapbox-gl')
}

  1. project-name/android/settings.gradle

// Do the same as build.gradle by removing /, \, :, <, >, ", ?, *, | characters but remember don't remove in the projectDir
include ':mapbox-react-native-mapbox-gl'
project(':mapbox-react-native-mapbox-gl').projectDir = new File(rootProject.projectDir, '../node_modules/@mapbox/react-native-mapbox-gl/android/rctmgl')