在将React-native-firebase添加到应用程序后尝试构建我的react native项目会导致它无法构建应用程序。我收到以下错误:
* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find com.google.android.gms:play-services-measurement-api:9.8.0.
Searched in the following locations:
file:/Users/cliffc/Library/Android/sdk/extras/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
file:/Users/cliffc/Library/Android/sdk/extras/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
file:/Users/cliffc/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
file:/Users/cliffc/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
file:/Users/cliffc/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
file:/Users/cliffc/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
file:/Users/cliffc/.m2/repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
file:/Users/cliffc/.m2/repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
https://repo.maven.apache.org/maven2/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
https://repo.maven.apache.org/maven2/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
https://jcenter.bintray.com/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
https://jcenter.bintray.com/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
file:/Users/cliffc/projects/prod/commconn/cc/node_modules/react-native/android/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
file:/Users/cliffc/projects/prod/commconn/cc/node_modules/react-native/android/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
https://maven.google.com/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
https://maven.google.com/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
https://jitpack.io/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
https://jitpack.io/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
Required by:
project :app > com.google.firebase:firebase-core:16.0.3 > com.google.firebase:firebase-measurement-connector-impl:17.0.1
project :app > com.google.android.gms:play-services:9.8.0 > com.google.firebase:firebase-analytics:16.0.3
这只是其中之一,对于以下服务,我也会遇到相同的错误:
Could not find com.google.android.gms:play-services-measurement-base:9.8.0.
Could not find com.google.android.gms:play-services-stats:9.8.0.
Could not find com.google.android.gms:play-services-ads-identifier:9.8.0.
我的MainApplication获取软件包是:
protected List<ReactPackage> getPackages() {
// Add additional packages you require here
// No need to add RnnPackage and MainReactPackage
mCallbackManager = new CallbackManager.Factory().create();
return Arrays.<ReactPackage>asList(new MapsPackage(), new RNDeviceInfo(), new FBSDKPackage(mCallbackManager),
new PickerPackage(), new RNFetchBlobPackage(), new VectorIconsPackage(),
new ReactNativePushNotificationPackage(), new RNFirebasePackage());
// eg. new VectorIconsPackage()
}
Build.gradle(应用程序):
ext {
compileSdkVersion = 27
targetSdkVersion = 27
buildToolsVersion = "27.0.1"
supportLibVersion = "26.1.0"
googlePlayServicesVersion = "15.0.1"
androidMapsUtilsVersion = "0.5+"
firebaseVersion = "+"
}
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
defaultConfig {
applicationId "com.commonconnectapp"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
minSdkVersion 16
targetSdkVersion 27
versionCode 22
versionName "1.0.1"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.getRequested().getGroup() == 'com.google.android.gms') {
details.useVersion('9.8.0')
}
}
}
dependencies {
compile project(':react-native-firebase')
compile project(':react-native-push-notification')
compile project(':react-native-maps')
compile project(':react-native-image-picker')
compile project(':react-native-fbsdk')
compile project(':rn-fetch-blob')
compile project(':react-native-vector-icons')
compile project(':react-native-image-crop-picker')
compile project(':react-native-device-info')
compile fileTree(dir: "libs", include: ["*.jar"])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:multidex:1.0.3'
// compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-maps')
compile project(':react-native-navigation')
implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
implementation project(':react-native-fbsdk')
implementation project(':react-native-firebase')
implementation "com.google.firebase:firebase-core:16.0.3"
compile "com.google.android.gms:play-services:15.0.1"
}
非常感谢您的帮助。如果需要更多信息,请告诉我。我一直在搜索,并尝试了一些修复措施都无济于事。我会继续研究并在发现答案后自行添加答案。
答案 0 :(得分:0)
类似的事情以前发生在我身上。当您像这样安装本机依赖项时,在android studio中,除了主要的本机应用程序外,您还会看到其他项目。
如果正确安装了其中的一个,则这些项目之一应该是本机Firebase。 好吧,这个项目与您的主应用程序项目一样,也有一个带有依赖项的gradle文件。
检查是否存在错误指定的库,并且该库的版本与主应用程序中的gms服务相同。