Atheel Massalha
Atheel Massalha

Reputation: 464

How to use Firebase in Android?

I am getting mad from gradle issues after adding Firebase to my app, I get the error: class file for com.google.android.gms.internal.zzbgl not found

I am using android location and url stringRequest, until then it worked well, then I have added Firebase to the gradle (I have registered in the Firebase website and added the generated google-services.json)

I checked for alot of answeres that didnt help, I have updated gradle to 3.4.2 still not working

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    defaultConfig {
        applicationId "com.example.mapwithmarker"
        minSdkVersion 22
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        resValue "string", "google_maps_key", (project.findProperty("GOOGLE_MAPS_API_KEY") ?: "")
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.android.gms:play-services:12.0.1'
    implementation 'com.mcxiaoke.volley:library:1.0.19'
    implementation 'com.google.firebase:firebase-core:17.0.1'
    testImplementation 'junit:junit:4.12'
}

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


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

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

allprojects {
    repositories {
        jcenter()
        google()
    }
}

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

any help please?

Upvotes: 1

Views: 369

Answers (4)

Atheel Massalha
Atheel Massalha

Reputation: 464

Fixed by: ...

    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.android.gms:play-services:12.0.1'
    implementation 'com.mcxiaoke.volley:library:1.0.19'
    implementation 'com.google.firebase:firebase-core:12.0.1'
    testImplementation 'junit:junit:4.12'
}

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

thanks

Upvotes: 0

Riyasa Mansil
Riyasa Mansil

Reputation: 190

As mentioned from official docs,

“ Don't use the combined play-services target. It brings in dozens of libraries, bloating your application. Instead, specify only the specific Google Play services APIs your app uses.”

you should not use combined play services library. Instead try using specific libraries you need and try updating the specific library to 17.0.0

Upvotes: 1

POMAIIIUK
POMAIIIUK

Reputation: 509

Use this Firebase documentation.

Or follow this:

Tools -> Firebase -> Choose your library -> Follow instructions

enter image description here enter image description here enter image description here

Upvotes: 0

abd3llatif
abd3llatif

Reputation: 330

You should always use the compatible versions of your firebase and play-services libs. the version should be released at the same time.

In this case

Change this line :

implementation 'com.google.android.gms:play-services:12.0.1'

With this one :

implementation 'com.google.android.gms:play-services:17.0.1'

Upvotes: 0

Related Questions