gpt4 book ai didi

android - React Native Android突然找不到Google服务

转载 作者:行者123 更新时间:2023-12-03 04:30:29 25 4
gpt4 key购买 nike

昨天我很高兴在iOS和Android上编译我的应用程序。当我回来时,Android上不再起作用。

google-services plugin could not detect any version for com.google.android.gms or com.google.firebase, default version: 9.0.0 will be used. please apply google-services plugin at the bottom of the build file.



该消息非常简单,在将依赖项安装到应用程序中时,我已经不得不处理几次。而且我一直设法解决这个问题。但是这一次它没有任何明显的原因显示,因为我没有触摸我的android SDK。

此外,我的gradle配置文件也没有被触摸过。在下面,您将看到文件末尾还有 apply google-services plugin行。

为了以防万一,我尝试返回一个较旧的提交。但是事情还是一样,现在这个问题让我有些不知所措。

这是我的 app/gradle文件:
apply plugin: "com.android.application"

import com.android.build.OutputFile

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

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.myApp"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword 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 {
force 'com.google.android.gms:play-services-ads:9.2.1'
force "com.google.android.gms:play-services:9.2.1"
force "com.google.android.gms:play-services-location:9.2.1"
force "com.google.android.gms:play-services-maps:9.2.1"
force "com.google.android.gms:play-services-gcm:9.2.1"
force "com.google.android.gms:play-services-analytics:9.2.1"
force "com.google.firebase:firebase-core:9.2.1"
force "com.google.firebase:firebase-analytics:9.2.1"
}
}

dependencies {
compile project(':react-native-maps')
compile project(':react-native-linear-gradient')
compile fileTree(dir: "libs", include: ["*.jar"])
compile project(':react-native-fbsdk')
compile project(':react-native-firebase-analytics')
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}

// 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'

这是我的android SDK Manager的屏幕截图

SDK Manager screenshot

有人知道发生了什么吗?

最佳答案

我找到了解决问题的方法。其实我根本不知道为什么它能正常工作。

但是,通过阅读我的代码,我实际上看到了force是Firebase的一个版本,但从未真正编译过...所以我从force中删除了configuration,并将依赖关系移到了dependencies block

我真的不知道这是否是正确的解决方案
但这解决了我的问题:

configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-ads:9.2.1'
force "com.google.android.gms:play-services:9.2.1"
force "com.google.android.gms:play-services-location:9.2.1"
force "com.google.android.gms:play-services-maps:9.2.1"
force "com.google.android.gms:play-services-gcm:9.2.1"
force "com.google.android.gms:play-services-analytics:9.2.1"
}
}

dependencies {
compile project(':react-native-maps')
compile project(':react-native-linear-gradient')
compile fileTree(dir: "libs", include: ["*.jar"])
compile project(':react-native-fbsdk')
compile project(':react-native-firebase-analytics')
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile "com.google.firebase:firebase-core:9.2.1"
compile "com.google.firebase:firebase-analytics:9.2.1"
}

关于android - React Native Android突然找不到Google服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39532479/

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