Реализация response-native-firebase невозможна в существующем проекте (response-native @ .54). сборка gradle не удалась - PullRequest
0 голосов
/ 28 августа 2018

Я попытался реализовать firebase в моем существующем реактивном проекте, и сборка gradle не удалась.

Но реализовано в новом проекте (реагировать-родной @ .55.4) без каких-либо проблем, я не очень хорош в Android, Так что не могу понять, в чем проблема при настройке проекта.

Основные ошибки в сборке Gradle

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.

Ошибка полной сборки Gradle:

**> 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
**

файл 'android / build.gradle'

// 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"
            }
        }
    }
}

файл 'android / app / build.gradle'

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

Значение distributionUrl в 'gradle-wrapper.properties' равно 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 Ответ

0 голосов
/ 28 августа 2018

В вашем 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 должны использовать одну и ту же версию.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...