gpt4 book ai didi

Android studio 错误 - 使用 firebase react native

转载 作者:行者123 更新时间:2023-11-29 01:00:02 31 4
gpt4 key购买 nike

我收到这个错误:

The library com.google.android.gms:play-services-basement is being requested by various other libraries at [[15.0.1,15.0.1], [15.0.0,15.0.0]], but resolves to 15.0.1. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

android/build.gradle

buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.0.1'
}
}

allprojects {
repositories {
mavenLocal()
jcenter()

/// notice the same objecct maven, but with different url
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://maven.google.com'
}
}
}

android/app/build.gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile


project.ext.react = [
entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"


def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.xapp1"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
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"
}
}
// 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
}
}
}
}

dependencies {
implementation(project(':react-native-firebase')) {
transitive = false
}
// implementation project(':react-native-config')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:23.0.1"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.android.gms:play-services-base:11.6.0"
// Firebase dependencies
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation "com.google.firebase:firebase-firestore:17.0.2"
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'

请帮助我,我正在寻找解决方案大约 4 天,谢谢。

最佳答案

将您的 react-native-firebase 更新到 v4.3.8 版本,然后执行 npm 或 yarn install。

然后如下配置你的app/build.gradle,

dependencies {
// Other dependencies for react-native

// RNFirebase
implementation project(':react-native-firebase')

// RNFirebase required dependencies
implementation "com.google.android.gms:play-services-base:15.0.1"
implementation "com.google.firebase:firebase-core:16.0.1"

// RNFirebase optional depedencies
implementation "com.google.firebase:firebase-firestore: 17.0.4"

}

您收到的错误是由于直接或传递依赖项版本不匹配。

从 react-native-firebase 的示例项目中查看 app/build.gradle 文件,

https://github.com/invertase/react-native-firebase/blob/master/bridge/android/app/build.gradle

使用正确的版本,判断它是否有效。谢谢

关于Android studio 错误 - 使用 firebase react native ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51921380/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com