当前位置: 首页 > 知识库问答 >
问题:

react-native-firebase实现在现有项目中是不可能的(React-Native@.54)。分级构建失败

高朝明
2023-03-14

我试图在现有的react-native项目中实现firebase,但gradle构建失败了。

找不到com.google.android.gms:play-services-stats:9.8.0.

找不到com.google.android.gms:play-services-ads-identifier:9.8.0.

分级构建完全错误:

**> Task :react-native-fast-image:processDebugManifest 
/var/www/html/travalour/react-native-app/node_modules/react-native-fast-image/android/src/main/AndroidManifest.xml:11:9-15:15 Warning:
        meta-data#com.bumptech.glide.integration.okhttp.OkHttpGlideModule was tagged at AndroidManifest.xml:11 to remove other declarations but no other declaration present


FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find com.google.android.gms:play-services-measurement-base:9.8.0.
  Searched in the following locations:
      file:/home/cyberinfoscripter/Android/Sdk/extras/m2repository/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/m2repository/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.aar
      file:/home/cyberinfoscripter/Android/Sdk/extras/google/m2repository/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/google/m2repository/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.aar
      file:/home/cyberinfoscripter/Android/Sdk/extras/android/m2repository/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/android/m2repository/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.aar
      file:/home/cyberinfoscripter/.m2/repository/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.pom
      file:/home/cyberinfoscripter/.m2/repository/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.aar
      https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.pom
      https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.aar
      https://jcenter.bintray.com/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.pom
      https://jcenter.bintray.com/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.aar
      file:/var/www/html/travalour/react-native-app/node_modules/react-native/android/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.pom
      file:/var/www/html/travalour/react-native-app/node_modules/react-native/android/com/google/android/gms/play-services-measurement-base/9.8.0/play-services-measurement-base-9.8.0.aar
  Required by:
      project :app > com.google.firebase:firebase-core:16.0.1 > com.google.firebase:firebase-analytics:16.0.1
      project :app > com.google.firebase:firebase-core:16.0.1 > com.google.firebase:firebase-measurement-connector-impl:16.0.1
      project :app > com.google.firebase:firebase-core:16.0.1 > com.google.firebase:firebase-analytics:16.0.1 > com.google.firebase:firebase-analytics-impl:16.1.1
> Could not find com.google.android.gms:play-services-stats:9.8.0.
  Searched in the following locations:
      file:/home/cyberinfoscripter/Android/Sdk/extras/m2repository/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/m2repository/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.aar
      file:/home/cyberinfoscripter/Android/Sdk/extras/google/m2repository/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/google/m2repository/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.aar
      file:/home/cyberinfoscripter/Android/Sdk/extras/android/m2repository/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/android/m2repository/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.aar
      file:/home/cyberinfoscripter/.m2/repository/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.pom
      file:/home/cyberinfoscripter/.m2/repository/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.aar
      https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.pom
      https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.aar
      https://jcenter.bintray.com/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.pom
      https://jcenter.bintray.com/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.aar
      file:/var/www/html/travalour/react-native-app/node_modules/react-native/android/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.pom
      file:/var/www/html/travalour/react-native-app/node_modules/react-native/android/com/google/android/gms/play-services-stats/9.8.0/play-services-stats-9.8.0.aar
  Required by:
      project :app > com.google.firebase:firebase-core:16.0.1 > com.google.firebase:firebase-analytics:16.0.1
      project :app > com.google.firebase:firebase-core:16.0.1 > com.google.firebase:firebase-analytics:16.0.1 > com.google.firebase:firebase-analytics-impl:16.1.1
      project :app > com.google.firebase:firebase-core:16.0.1 > com.google.firebase:firebase-analytics:16.0.1 > com.google.firebase:firebase-analytics-impl:16.1.1 > com.google.firebase:firebase-iid:16.0.0
> Could not find com.google.android.gms:play-services-ads-identifier:9.8.0.
  Searched in the following locations:
      file:/home/cyberinfoscripter/Android/Sdk/extras/m2repository/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/m2repository/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.aar
      file:/home/cyberinfoscripter/Android/Sdk/extras/google/m2repository/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/google/m2repository/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.aar
      file:/home/cyberinfoscripter/Android/Sdk/extras/android/m2repository/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.pom
      file:/home/cyberinfoscripter/Android/Sdk/extras/android/m2repository/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.aar
      file:/home/cyberinfoscripter/.m2/repository/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.pom
      file:/home/cyberinfoscripter/.m2/repository/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.aar
      https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.pom
      https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.aar
      https://jcenter.bintray.com/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.pom
      https://jcenter.bintray.com/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.aar
      file:/var/www/html/travalour/react-native-app/node_modules/react-native/android/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.pom
      file:/var/www/html/travalour/react-native-app/node_modules/react-native/android/com/google/android/gms/play-services-ads-identifier/9.8.0/play-services-ads-identifier-9.8.0.aar
  Required by:
      project :app > com.google.firebase:firebase-core:16.0.1 > com.google.firebase:firebase-analytics:16.0.1 > com.google.firebase:firebase-analytics-impl:16.1.1

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

* Get more help at https://help.gradle.org

BUILD FAILED in 14s
24 actionable tasks: 24 executed
**
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'com.google.gms:google-services:4.0.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }

    }
}

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "26.1.0"
            }
        }
    }
}
apply plugin: "com.android.application"
project.ext.envConfigFiles = [
    debug: ".env.development",
    release: ".env.production",
    anothercustombuild: ".env",
]
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

import com.android.build.OutputFile

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

apply from: "../../node_modules/react-native/react.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 26
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId "com.travalour"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        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
            }
        }
    }
}

//added the configurations.all for making the map work
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.getRequested().getGroup() == 'com.google.android.gms') {
            details.useVersion('9.8.0')
        }
    }
}

dependencies {
    implementation project(':react-native-firebase')
    // Firebase dependencies
    implementation "com.google.android.gms:play-services-base:15.0.1"
    implementation "com.google.firebase:firebase-core:16.0.1"
    implementation project(':react-native-fast-image')
    implementation project(':realm')
    implementation project(':react-native-google-signin')
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-fetch-blob')
    implementation project(':react-native-config')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-video')
    implementation project(':react-native-device-info')
    implementation project(':realm')
    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(project(':react-native-maps')){
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    implementation 'com.google.android.gms:play-services-maps:10.0.1'
    implementation('com.facebook.android:facebook-android-sdk:[4,5)')
}

// 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/settings.gradle'文件

rootProject.name = 'Travalour'
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
include ':react-native-fast-image'
project(':react-native-fast-image').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fast-image/android')
include ':react-native-fetch-blob'
project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fetch-blob/android')
include ':react-native-config'
project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android')
include ':react-native-google-signin'
project(':react-native-google-signin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-signin/android')
include ':react-native-fbsdk'
project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':realm'
project(':realm').projectDir = new File(rootProject.projectDir, '../node_modules/realm/android')
include ':app'
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')

'gradle-wrapper.properties'中的distributionUrl值为https\://services.gradle.org/distributions/gradle-4.4-all.zip

已安装的节点模块:

+-- @expo/vector-icons@6.3.1
+-- @expo/videoplayer@0.4.0
+-- aws-sdk@2.267.1
+-- axios@0.18.0
+-- babel-plugin-dotenv@0.1.1
+-- babel-preset-react-native@4.0.0
+-- babel-preset-react-native-stage-0@1.0.1
+-- buffer@5.1.0
+-- eslint-config-rallycoding@3.2.0
+-- UNMET PEER DEPENDENCY expo@>=22.0.0
+-- jest@22.4.4
+-- jest-react-native@18.0.0
+-- lodash@4.17.10
+-- moment@2.22.2
+-- UNMET PEER DEPENDENCY react@16.3.0-alpha.1
+-- UNMET PEER DEPENDENCY react-dom@*
+-- UNMET PEER DEPENDENCY react-native@0.54.0
+-- react-native-config@0.11.5
+-- react-native-device-info@0.21.5
+-- react-native-dotenv@0.1.1
+-- react-native-fast-image@4.0.14
+-- react-native-fbsdk@0.7.0
+-- react-native-fetch-blob@0.10.8
+-- react-native-firebase@4.3.8
+-- react-native-google-places-autocomplete@1.3.6
+-- react-native-google-signin@0.12.0
+-- react-native-maps@0.21.0
+-- react-native-read-more-text@1.1.0
+-- react-native-router-flux@4.0.0-beta.31
+-- react-native-scalable-image@0.4.0
+-- react-native-vector-icons@4.6.0
+-- react-native-video@2.3.1
+-- react-native-video-controls@2.2.3
+-- react-native-video-player@0.9.1
+-- react-redux@5.0.7
+-- react-test-renderer@16.3.0-alpha.1
+-- react-timestamp@4.4.0
+-- realm@2.12.0
+-- redux@3.7.2
+-- redux-thunk@2.3.0
-- socket.io-client@2.1.1

共有1个答案

璩正志
2023-03-14

在您的Android/app/build.gradle中,您需要删除:

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.getRequested().getGroup() == 'com.google.android.gms') {
            details.useVersion('9.8.0')
        }
    }
}

还将您的依赖项更新为:

dependencies {
    implementation project(':react-native-firebase')
    // Firebase dependencies
    implementation "com.google.android.gms:play-services-base:16.0.1"
    implementation "com.google.firebase:firebase-core:16.0.1"
    implementation project(':react-native-fast-image')
    implementation project(':realm')
    implementation project(':react-native-google-signin')
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-fetch-blob')
    implementation project(':react-native-config')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-video')
    implementation project(':react-native-device-info')
    implementation project(':realm')
    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(project(':react-native-maps')){
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    implementation 'com.google.android.gms:play-services-maps:16.0.1'
    implementation('com.facebook.android:facebook-android-sdk:[4,5)')
}

您的google依赖项应该使用相同的版本。

 类似资料:
  • 我在iOS中有一个相当复杂的React原生项目,我想把它移植到Android上,测试它的可移植性。我已经完成了以下标准安装说明: '安装最新的JDK安装Android SDK:On Mac:brew安装Android SDK导出Android_HOME=/usr/local/opt/Android SDK打开Android SDK管理器(在Mac上启动新的shell并运行Android);在出现的

  • 错误,无法安装应用程序。确保您已经设置了Android开发环境:https://reactnative.dev/docs/environment-setup。运行带有--verbose标志的CLI以获得更多详细信息。错误:命令失败:./gradlew app:installdebug-preactnativedevserverport=8081 失败:生成失败,出现异常。 在6s中生成失败 MY

  • 当我尝试使用./gradlew bundleRelise构建apk文件时,我遇到了这个错误 失败:构建失败,但有一个异常。 问题所在:任务“:app:bundleReleaseResources”的执行失败。 执行 com.android.build.gradle.internal.tasks.Workers$ActionFacade Android 资源链接失败 C:\Users\Yoan\Re

  • 当我试图在ios模拟器上运行应用程序时,我得到了这个。有谁能告诉我这个问题的原因/解决办法是什么。 以下构建命令失败:CompileC/users/xxx/library/developer/xcode/deriveddata/eattog-dfbqbeyhmbgzhfcodvhcaqjxepf/build/intermediates.noindex/p s.llvm.clang.1_0.comp

  • 问题内容: 我正在尝试创建一个新的react native项目,该项目应该使用旧版本的react-native。 我想要的结果将是做类似的事情:但有使用它的react-native版本。 但是,似乎没有任何选项可用于使用旧版本的react-native进行初始化。 执行然后降级react-native 也不起作用,因为该命令会安装一堆用于构建应用程序的xcode模板,并且没有命令可以降级这些模板。

  • React Native Firebase React Native Firebase is a collection of official React Native modules connecting you to Firebase services; each module is a light-weight JavaScript layer connecting you to the n