firebase databasereference gives no virtual method error

泪湿孤枕 提交于 2019-12-24 07:00:09

问题


I am trying to add firebase database some info by getting database reference but it gives the fallowing error:

Caused by: java.lang.NoSuchMethodError: No virtual method zzckb()Z in class Lcom/google/firebase/FirebaseApp; or its super classes (declaration of 'com.google.firebase.FirebaseApp' appears in /data/app/com.bogroup.ucuncuprogram-1/split_lib_dependencies_apk.apk:classes25.dex)

My java code is lke the fallowing:

package com.bogroup.ucuncuprogram;

import android.content.Context;
import android.widget.Toast;
import com.firebase.client.Firebase;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import static com.facebook.FacebookSdk.getApplicationContext;

public class database{

    private Firebase mRootRef;
    private DatabaseReference mDatabase;


    public void kullanicikontrol(String kullaniciadi){
        mDatabase = FirebaseDatabase.getInstance().getReference();
        mDatabase.child("users").child(kullaniciadi).setValue("9999999");
        //chieldref.setValue("9999999");

        Context context = getApplicationContext();
        CharSequence text = kullaniciadi;
        int duration = Toast.LENGTH_LONG;

        Toast toast = Toast.makeText(context, text, duration);
        toast.show();
    }
}

What may be the problem, thanks in advance.

My app build.grade is like fallowing:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.bogroup.ucuncuprogram"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    packagingOptions {
        exclude 'META-INF/NOTICE' // will not include NOTICE file
        exclude 'META-INF/LICENSE' // will not include LICENSE file
        // as noted by @Vishnuvathsan you may also need to include
        // variations on the file name. It depends on your dependencies.
        // Some other common variations on notice and license file names
        exclude 'META-INF/notice'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license'
        exclude 'META-INF/license.txt'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-core:9.4.0'
    compile 'com.google.firebase:firebase-auth:9.4.0'
    compile 'com.google.firebase:firebase-database:9.4.0'
    compile 'com.google.firebase:firebase-crash:9.4.0'
    compile 'com.firebase:firebase-client-android:2.2.4'
    //compile 'com.google.firebase:firebase-storage:9.4.0'
    compile 'com.firebaseui:firebase-ui:0.4.4'
    compile 'com.google.android.gms:play-services-auth:9.4.0'
    compile 'com.android.support:animated-vector-drawable:25.0.0'
    compile 'com.android.support:design:25.0.0'
    compile 'com.android.support:support-v4:25.0.0'
    compile 'com.android.support:cardview-v7:25.0.0'
    compile 'com.android.support:customtabs:25.0.0'
    compile 'com.android.support:recyclerview-v7:25.0.0'
    compile 'com.firebaseui:firebase-ui-auth:1.2.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    //compile 'com.android.support:customtabs:25.2.0'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

回答1:


Your versions of Firebase and Firebase UI need to line up according to the table on their Github Page.

For reference, should you choose to upgrade (I would highly recommend it).

FirebaseUI Version
1.2.0

Firebase/Play Services Version
10.2.0

Easy way to do this

ext {
    googlePlayVer = "10.2.0"
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'

    // For example
    compile "com.google.firebase:firebase-core:${googlePlayVer}"
    compile "com.google.firebase:firebase-auth:${googlePlayVer}"
    compile "com.google.firebase:firebase-database:${googlePlayVer}"


来源:https://stackoverflow.com/questions/44447837/firebase-databasereference-gives-no-virtual-method-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!