【问题标题】:Unable to resolve dependencies react native google fit无法解决依赖关系反应原生谷歌适合
【发布时间】:2018-04-11 22:22:03
【问题描述】:

添加包后,我无法构建项目。错误:

配置项目 ':app' 时出现问题。

> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':react-native-google-fit'.
      > Could not resolve all dependencies for configuration ':react-native-google-fit:_debugPublishCopy'.
         > Could not find com.google.android.gms:play-services-auth:11.6.0.
           Searched in the following locations:
               file:/Users/wojciech/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-auth/11.6.0/play-services-auth-11.6.0.pom
               file:/Users/wojciech/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-auth/11.6.0/play-services-auth-11.6.0.jar
               file:/Users/wojciech/Documents/dev/uni/swifty-app/Swifty/android/sdk-manager/com/google/android/gms/play-services-auth/11.6.0/play-services-auth-11.6.0.jar
               file:/Users/wojciech/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-auth/11.6.0/play-services-auth-11.6.0.pom
               file:/Users/wojciech/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-auth/11.6.0/play-services-auth-11.6.0.jar
               file:/Users/wojciech/Documents/dev/uni/swifty-app/Swifty/android/sdk-manager/com/google/android/gms/play-services-auth/11.6.0/play-services-auth-11.6.0.jar
           Required by:
               Swifty:react-native-google-fit:unspecified
         > Could not find com.google.android.gms:play-services-fitness:11.6.0.
           Searched in the following locations:
               file:/Users/wojciech/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-fitness/11.6.0/play-services-fitness-11.6.0.pom
               file:/Users/wojciech/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-fitness/11.6.0/play-services-fitness-11.6.0.jar
               file:/Users/wojciech/Documents/dev/uni/swifty-app/Swifty/android/sdk-manager/com/google/android/gms/play-services-fitness/11.6.0/play-services-fitness-11.6.0.jar
               file:/Users/wojciech/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-fitness/11.6.0/play-services-fitness-11.6.0.pom
               file:/Users/wojciech/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-fitness/11.6.0/play-services-fitness-11.6.0.jar
               file:/Users/wojciech/Documents/dev/uni/swifty-app/Swifty/android/sdk-manager/com/google/android/gms/play-services-fitness/11.6.0/play-services-fitness-11.6.0.jar
           Required by:
               Swifty:react-native-google-fit:unspecified

提前致谢。

【问题讨论】:

  • 只是因为这是 StackOverflow React Native 问题上非常常见的错误,我不得不问:您是否按照说明完成?这是一个原生模块,所以仅仅添加包是行不通的;您还需要进行链接,对于这个特定的包,还需要一些手动步骤。除此之外,如果您使用react-react-native-app 或Expo,如果不弹出/分离,这将无法工作。

标签: react-native google-fit


【解决方案1】:

有两种常见的解决方法。 1. 添加到你的 android/build.gradle 文件,在 allprojects/repositoris 部分下

maven {
        url 'https://maven.google.com'
}

所以它应该看起来像:

allprojects {
    repositories {
        mavenLocal()
        maven {
            url 'https://maven.google.com'
        }
        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://jitpack.io" }
        jcenter()
    }
}
  1. 另一种方式(对我有用) - 用于 react-native-google-fit lib,并在库的 android/build.gradle 中将依赖项更改为

    编译'com.google.android.gms:play-services-auth+'

    编译'com.google.android.gms:play-services-fitness+'

在你的项目中使用你的 fork

【讨论】:

    猜你喜欢
    • 2020-02-07
    • 1970-01-01
    • 2016-02-16
    • 2017-02-20
    • 1970-01-01
    相关资源
    最近更新 更多