Android系统。 Firebase:无法解析Android应用程序模块

时间:2017-09-19 17:33:39

标签: android firebase

我的build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.1.3-2'
    ext.realm_version = '3.7.2'

    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.1.0'
        classpath "io.realm:realm-gradle-plugin:$realm_version"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://maven.google.com" }
        maven { url 'https://dl.bintray.com/jetbrains/anko' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
repositories {
    mavenCentral()
}

我的app / build.gradle

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'

realm {
    syncEnabled = true;
}

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

android {
    compileSdkVersion 26
    buildToolsVersion "25.0.3"
    dexOptions {
        jumboMode = true
    }


    defaultConfig {
        applicationId "com.my.project"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 54
        versionName "1.3.54"

        multiDexEnabled true

    }
}

def AAVersion = '4.3.1'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.0@aar') {
        transitive = true;
    }
    compile('com.digits.sdk.android:digits:1.11.0@aar') {
        transitive = true;
    }
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.baoyz.swipemenulistview:library:1.3.0'
    compile 'com.google.android.gms:play-services-gcm:11.0.4'
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.miguelcatalan:materialsearchview:1.4.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.7.3'
    compile 'com.squareup.okhttp:okhttp:2.7.3'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.2.5'
    compile 'commons-codec:commons-codec:1.9'
    compile 'commons-io:commons-io:2.4'
    compile 'io.realm:android-adapters:2.0.0'
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'org.apache.httpcomponents:httpcore:4.4.4'
    compile 'org.apache.httpcomponents:httpmime:4.3.6'
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    compile 'us.feras.mdv:markdownview:1.1.0'
    compile 'org.jetbrains.anko:anko-sdk15:0.9.1'
    compile "org.androidannotations:androidannotations-api:$AAVersion"


    // for annotaions
    kapt "io.realm:realm-android-library:$realm_version"
    kapt "org.androidannotations:androidannotations:$AAVersion"

    compile 'com.firebaseui:firebase-ui-auth:2.3.0'
    compile 'com.google.firebase:firebase-auth:11.0.4'
    compile "com.android.support:design:26.1.0"
    compile "com.android.support:customtabs:26.1.0"
    compile "com.android.support:cardview-v7:26.1.0"

    testCompile 'junit:junit:4.12'
}

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

当我构建时,我收到错误:

Error:Execution failed for task ':app:processDevGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it. 
   Searched Location: 
  com\my_project\app\src\dev\google-services.json
com\my_project\\app\google-services.json

确定。在Android Studio选择菜单中:工具 - > Friebase

  1. Firebase->鉴别
  2. 点击电子邮件和密码验证
  3. 将您的应用连接到Firebase
  4. 并收到错误:

    Could not parse the Android Application module

3 个答案:

答案 0 :(得分:2)

我刚刚解决了这个问题。 我正在将旧的GCM升级到FCM,Firebase助理会显示与您相同的错误消息。

解决方案:

  1. 转到Firebase控制台,在我的项目的设置中,将google-servics.json下载到app/文件夹。 (替换我原来的GCM' json文件)

  2. 再次执行Add Firebase to your app

  3. 然后我可以再次使用AndroidStudio的Firebase Assistans。

答案 1 :(得分:2)

对我来说,问题是类路径“ com.google.gms:google-services:4.3.0”给出了错误,然后我更改为类路径“ com.google.gms:google-services:4.2.0”,重新同步“带有Gradle文件的项目”,然后按连接到Firebase:D

答案 2 :(得分:-1)

您可能想尝试“使用Gradle文件同步项目”。

有时,在将实现添加到gradle文件中后,我忘记了同步实现。