本机反应无法找到com.google.firebase

时间:2017-09-06 17:44:04

标签: android firebase react-native

我最近将我的反应原生应用程序驱逐到了Expokit。我正在尝试使用react native firebase。按照android installation page上给出的响应本机firebase的设置说明后,当我执行'react-native run-android'时,我收到一条错误:“找不到com.google.firebase:firebase-core:11.2。 0" 。请注意,正如在其他SO页面上给出的那样,我已经从Android工作室安装了Google Play服务和Google存储库,但即使这样做,我仍然会收到错误消息。这是'react-native run-android'的完整输出:

Scanning 885 folders for symlinks in /Users/aksheyjawa/Misc/mobiledev/reactNative/SRFYSSapp/node_modules (23ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /Users/aksheyjawa/Library/Android/sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /Users/aksheyjawa/Library/Android/sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

Incremental java compilation is an incubating feature.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
   > Could not find com.google.firebase:firebase-core:11.2.0.
     Searched in the following locations:
         file:/Users/aksheyjawa/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.pom
         file:/Users/aksheyjawa/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.jar
         file:/Users/aksheyjawa/Misc/mobiledev/reactNative/SRFYSSapp/android/sdk-manager/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.jar
         file:/Users/aksheyjawa/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.pom
         file:/Users/aksheyjawa/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.jar
         file:/Users/aksheyjawa/Misc/mobiledev/reactNative/SRFYSSapp/android/sdk-manager/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.jar
     Required by:
         project :app
   > Could not find com.google.android.gms:play-services-base:11.2.0.
     Searched in the following locations:
         file:/Users/aksheyjawa/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-base/11.2.0/play-services-base-11.2.0.pom
         file:/Users/aksheyjawa/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-base/11.2.0/play-services-base-11.2.0.jar
         file:/Users/aksheyjawa/Misc/mobiledev/reactNative/SRFYSSapp/android/sdk-manager/com/google/android/gms/play-services-base/11.2.0/play-services-base-11.2.0.jar
         file:/Users/aksheyjawa/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-base/11.2.0/play-services-base-11.2.0.pom
         file:/Users/aksheyjawa/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-base/11.2.0/play-services-base-11.2.0.jar
         file:/Users/aksheyjawa/Misc/mobiledev/reactNative/SRFYSSapp/android/sdk-manager/com/google/android/gms/play-services-base/11.2.0/play-services-base-11.2.0.jar
     Required by:
         project :app
   > Could not find com.google.firebase:firebase-analytics:11.2.0.
     Searched in the following locations:
         file:/Users/aksheyjawa/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-analytics/11.2.0/firebase-analytics-11.2.0.pom
         file:/Users/aksheyjawa/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-analytics/11.2.0/firebase-analytics-11.2.0.jar
         file:/Users/aksheyjawa/Misc/mobiledev/reactNative/SRFYSSapp/android/sdk-manager/com/google/firebase/firebase-analytics/11.2.0/firebase-analytics-11.2.0.jar
         file:/Users/aksheyjawa/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-analytics/11.2.0/firebase-analytics-11.2.0.pom
         file:/Users/aksheyjawa/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-analytics/11.2.0/firebase-analytics-11.2.0.jar
         file:/Users/aksheyjawa/Misc/mobiledev/reactNative/SRFYSSapp/android/sdk-manager/com/google/firebase/firebase-analytics/11.2.0/firebase-analytics-11.2.0.jar
     Required by:
         project :app
   > Could not find com.google.android.gms:play-services-base:11.2.0.
     Searched in the following locations:
         file:/Users/aksheyjawa/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-base/11.2.0/play-services-base-11.2.0.pom
         file:/Users/aksheyjawa/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-base/11.2.0/play-services-base-11.2.0.jar
         file:/Users/aksheyjawa/Misc/mobiledev/reactNative/SRFYSSapp/android/sdk-manager/com/google/android/gms/play-services-base/11.2.0/play-services-base-11.2.0.jar
         file:/Users/aksheyjawa/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-base/11.2.0/play-services-base-11.2.0.pom
         file:/Users/aksheyjawa/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-base/11.2.0/play-services-base-11.2.0.jar
         file:/Users/aksheyjawa/Misc/mobiledev/reactNative/SRFYSSapp/android/sdk-manager/com/google/android/gms/play-services-base/11.2.0/play-services-base-11.2.0.jar
     Required by:
         project :app > host.exp.exponent:expoview:19.0.0 > com.google.android.gms:play-services-analytics:9.8.0
         project :app > host.exp.exponent:expoview:19.0.0 > com.google.android.gms:play-services-gcm:9.8.0
         project :app > host.exp.exponent:expoview:19.0.0 > com.google.android.gms:play-services-location:9.8.0
         project :app > host.exp.exponent:expoview:19.0.0 > com.google.android.gms:play-services-fitness:9.8.0
         project :app > host.exp.exponent:expoview:19.0.0 > com.google.android.gms:play-services-auth:9.8.0
         project :app > host.exp.exponent:expoview:19.0.0 > com.google.android.gms:play-services-ads:9.8.0
         project :app > host.exp.exponent:expoview:19.0.0 > com.google.android.gms:play-services-maps:9.8.0
         project :app > host.exp.exponent:expoview:19.0.0 > com.google.android.gms:play-services-analytics:9.8.0 > com.google.android.gms:play-services-analytics-impl:9.8.0
         project :app > host.exp.exponent:expoview:19.0.0 > com.google.android.gms:play-services-gcm:9.8.0 > com.google.android.gms:play-services-iid:9.8.0
         project :app > host.exp.exponent:expoview:19.0.0 > com.google.android.gms:play-services-auth:9.8.0 > com.google.android.gms:play-services-auth-base:9.8.0
         project :app > host.exp.exponent:expoview:19.0.0 > com.google.android.gms:play-services-ads:9.8.0 > com.google.android.gms:play-services-clearcut:9.8.0

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 52.177 secs
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/android-setup.html

以下是build.gradle中的几行:

compile(project(':react-native-firebase')) {
  transitive = false
}
compile "com.google.firebase:firebase-core:11.2.0"
compile "com.google.android.gms:play-services-base:11.2.0"
compile "com.google.firebase:firebase-analytics:11.2.0"
apply plugin: 'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:4)

您需要添加Google maven repo,请参阅https://firebase.google.com/docs/android/setup#manually_add_firebase

在根build.gradle中应该有一个allprojects>依赖部分。在jcenter()下面添加maven repo:

maven {
    url "https://maven.google.com" // Google's Maven repository
}