后端模块中的Firebase Admin会触发“所有firebase库必须高于或低于14.0.0

时间:2018-05-06 08:47:27

标签: firebase android-studio gradle google-cloud-endpoints firebase-admin

我有一个android工作室项目,其中包含一个用于我的应用程序的模块和一个用于我后端的模块。

根据文档,我可以使用以下代码将所有构建端点库带到我的app模块:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.3'
        classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.5'
    }

}

repositories {
    jcenter(); }

apply plugin: 'java' apply plugin: 'war'

apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
    implementation 'com.google.endpoints:endpoints-framework:2.0.14'
    implementation 'javax.servlet:servlet-api:2.5'
    implementation 'javax.inject:javax.inject:1'
    implementation 'com.google.firebase:firebase-admin:5.11.0'
}

appengine {
    deploy {
        stopPreviousVersion = false
        promote = false
        version = '1'
        project = 'project-name'
    } }

在我的后端模块gradle中:

apply plugin: 'com.android.application'
apply plugin: 'com.google.cloud.tools.endpoints-framework-client'

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()
        jcenter()
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
        classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
    }
}

apply plugin: 'io.fabric'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "appID"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1"
        multiDexEnabled = true
        resConfigs "en", "fr"
    }

    dexOptions {
        javaMaxHeapSize "4g"
        preDexLibraries = false
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            zipAlignEnabled true
            debuggable false
        }
        debug {
            signingConfig null
        }
    }

}

repositories {
    flatDir {
        dirs 'libs'
    }
    mavenCentral()
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
        transitive = true;
    }

    implementation('com.firebaseui:firebase-ui-auth:3.3.1')
    implementation 'com.google.firebase:firebase-core:15.0.2'
    endpointsServer project(path: ':backend', configuration: 'endpoints')

    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.google.api-client:google-api-client-android:1.23.0'
    implementation 'com.google.http-client:google-http-client-android:1.23.0'
    implementation 'com.google.http-client:google-http-client-gson:1.23.0'
    implementation 'com.android.support:support-v4:27.1.0'
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.google.firebase:firebase-messaging:15.0.2'
    implementation 'com.google.android.gms:play-services-gcm:15.0.0'
    implementation 'com.google.firebase:firebase-auth:15.1.0'
    implementation 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.8.5'
    testImplementation 'junit:junit:4.12'
}

configurations {
    all {
        exclude module: 'httpclient'
    }
}

apply plugin: 'com.google.gms.google-services'

在我的app模块gradle中:

endpointsServer project(path: ':backend', configuration: 'endpoints')

问题是当gradle正在执行时会导致以下错误:

  

所有firebase库必须高于或低于14.0.0

我已经看过了:

How to add firebase-admin to my android project?android firebase admin sdk error 'All firebase libraries must be either above or below 14.0.0' [duplicate]

但是他们都试图在客户端添加admin sdk。这不是我想要做的原因。

那么我如何告诉gradle这是两个不同的模块,或者如何在我使用时排除admin sdk进入我的app模块:

import cv2
import numpy as np

from PIL import Image

import colorsys

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg

def rgb2gray(rgb):
return np.dot(rgb[...,:3], [0.299, 0.587, 0.114])

img = mpimg.imread('0.jpg')     
gray = rgb2gray(img)    
plt.imshow(gray, cmap = plt.get_cmap('gray'))
plt.show()

cv2.waitKey()
cv2.destroyAllWindows()

0 个答案:

没有答案