0

I tried to use firebase with android application. I added firebase libraries and follow some tutorials, but when I run there is an error.

my gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"


defaultConfig {
    applicationId "com.ring"
    minSdkVersion 15
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    multiDexEnabled true


}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
packagingOptions{
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE/FIREBASE.txt'
    exclude 'META-INF/NOTICE'
}
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.android.support:design:24.1.1'
    compile 'com.android.support:support-v4:24.1.1'
    compile 'com.firebase:firebase-client-android:2.3.1'
    compile "com.google.firebase:firebase-auth:9.0.2"
    compile 'com.google.android.gms:play-services-wearable:9.0.2'
    compile 'com.google.android.gms:play-services:9.0.2'
    compile 'com.android.support:multidex:1.0.1'

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

and my top level gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:2.1.2'
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
   }

allprojects {
    repositories {


        mavenCentral()
    }
}

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

the error apear when i run the project is

Java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
najlaa
  • 41
  • 1
  • 5

1 Answers1

1

Clean your project

Replace this

compile 'com.firebase:firebase-client-android:2.3.1'
compile "com.google.firebase:firebase-auth:9.0.2"

by

compile 'com.google.firebase:firebase-core:9.2.1'
compile 'com.google.firebase:firebase-database:9.2.1'
compile 'com.google.firebase:firebase-auth:9.2.1'

and delete this

packagingOptions{
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE/FIREBASE.txt'
exclude 'META-INF/NOTICE'}
Ahmad
  • 5,551
  • 8
  • 41
  • 57
shadaï ALI
  • 1,447
  • 1
  • 11
  • 11