NoSuchMethodError:类Lcom / google / firebase / FirebaseApp中没有虚方法zzEq()Z; [英] NoSuchMethodError: No virtual method zzEq()Z in class Lcom/google/firebase/FirebaseApp;

查看:155
本文介绍了NoSuchMethodError:类Lcom / google / firebase / FirebaseApp中没有虚方法zzEq()Z;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我在应用上遇到的致命错误。我正在尝试使用Firebase在我的应用程序上运行聊天信使功能。它一直在运行,但它一直在完全崩溃应用程序。我已经对代码进行了一些编辑以期解决问题,但无济于事。

Below is the fatal error that I keep getting on my App. I am trying to run a chat messenger feature on my application using Firebase. It was running however it has since kept crashing the app entirely. I've made a few edits to the code in the hope of resolving the issues, but to no avail.

我一直在关注youtbe https://www.youtube.com/watch?v=Xn0tQHpMDnM ,通过阅读评论说没有其他人有类似的错误。

I've been following this tutorial on youtbe https://www.youtube.com/watch?v=Xn0tQHpMDnM and it appears by reading the comments that no one else has a similiar error to me.

根据日志,错误发现在第99行 - displayChatMessage(); 以及第109行 - adapter = new FirebaseListAdapter< ChatMessage>(这,ChatMessage.class,R.layout.chat_list_item,FirebaseDatabase.getInstance()。getReference()) {

According to the log, the errors are found on line 99 - displayChatMessage(); as well as on Line 109 - adapter = new FirebaseListAdapter<ChatMessage>(this,ChatMessage.class,R.layout.chat_list_item,FirebaseDatabase.getInstance().getReference()) {

我希望这可能只是我创建的一个简单的代码错误,或者它可能与我有关gradle build。下面是我得到的错误日志。

I'm hoping this maybe just a simple code error which I have created, or is it possible it could be to do with my gradle build. Below is the error log I am getting.

FATAL EXCEPTION: main
                                                                                     Process: com.example.aids.a09application, PID: 30713
                                                                                     java.lang.NoSuchMethodError: No virtual method zzEq()Z in class Lcom/google/firebase/FirebaseApp; or its super classes (declaration of 'com.google.firebase.FirebaseApp' appears in /data/app/com.example.aids.a09application-2/split_lib_dependencies_apk.apk:classes33.dex)
                                                                                         at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
                                                                                         at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
                                                                                         at com.example.aids.a09application.MainChatActivity.displayChatMessage(MainChatActivity.java:109)
                                                                                         at com.example.aids.a09application.MainChatActivity.onCreate(MainChatActivity.java:99)
                                                                                         at android.app.Activity.performCreate(Activity.java:6912)
                                                                                         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
                                                                                         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2877)
                                                                                         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985)
                                                                                         at android.app.ActivityThread.-wrap14(ActivityThread.java)
                                                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635)
                                                                                         at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                         at android.os.Looper.loop(Looper.java:154)
                                                                                         at android.app.ActivityThread.main(ActivityThread.java:6692)
                                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
                                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

以下是聊天信使的MainActivity类在我的申请中:

Below is the MainActivity Class for the chat messenger in my application:

package com.example.aids.a09application;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.text.format.DateFormat;

import com.firebase.ui.auth.AuthUI;
import com.firebase.ui.database.FirebaseListAdapter;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.FirebaseDatabase;

/**
 * Created by Aids on 29/08/2017.
 */

public class MainChatActivity extends AppCompatActivity {

    private static int SIGN_IN_REQUEST_CODE = 1;
    private FirebaseListAdapter<ChatMessage> adapter;
    RelativeLayout chat_activity_main;
    FloatingActionButton fab;

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if(item.getItemId() == (R.id.menu_signout))
        {
            AuthUI.getInstance().signOut( this ).addOnCompleteListener( new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    Snackbar.make( chat_activity_main, "You have been signed out.", Snackbar.LENGTH_SHORT).show();
                    finish();

                }
            } );
        }
        return true;
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate( R.menu.chat_main_menu, menu );
        return true;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult( requestCode, resultCode, data );
        if (requestCode == SIGN_IN_REQUEST_CODE)
        {
            if(resultCode == RESULT_OK)
            {
                Snackbar.make( chat_activity_main, "Succesfully signed in. Welcome!", Snackbar.LENGTH_SHORT).show();
                displayChatMessage();
            }
            else {
                Snackbar.make( chat_activity_main, "We couldn't sign you in. Please try again!", Snackbar.LENGTH_SHORT).show();
                finish();
            }
        }
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.chat_activity_main );

        chat_activity_main = (RelativeLayout) findViewById( R.id.chat_activity_main );
        fab = (FloatingActionButton) findViewById( R.id.fab );
        fab.setOnClickListener( new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                EditText input = (EditText)findViewById( R.id.input );
                FirebaseDatabase.getInstance().getReference().push().setValue( new ChatMessage(input.getText().toString(),
                        FirebaseAuth.getInstance().getCurrentUser().getEmail()));
                input.setText( "" );

            }
        } );

        if (FirebaseAuth.getInstance().getCurrentUser() == null) {
            startActivityForResult( AuthUI.getInstance().createSignInIntentBuilder().build(), SIGN_IN_REQUEST_CODE );
        } else {
            Snackbar.make( chat_activity_main, "Welcome" + FirebaseAuth.getInstance().getCurrentUser().getEmail(), Snackbar.LENGTH_SHORT ).show();
            //Load Content
            displayChatMessage();
        }



    }

    private void displayChatMessage() {

        ListView listofMessage = (ListView) findViewById( R.id.list_of_messages );
        adapter = new FirebaseListAdapter<ChatMessage>(this,ChatMessage.class,R.layout.chat_list_item,FirebaseDatabase.getInstance().getReference()) {
            @Override
            protected void populateView(View v, ChatMessage model, int position) {
                //Get references to the views of chat_list_item.xml

                TextView messageText, messageUser, messageTime;
                messageText = (TextView) v.findViewById( R.id.message_text );
                messageUser = (TextView) v.findViewById( R.id.message_user );
                messageTime = (TextView) v.findViewById( R.id.message_time );

                messageText.setText( model.getMessageText() );
                messageUser.setText( model.getMessageUser() );
                messageTime.setText( DateFormat.format( "dd-mm-yyyy (HH:MM:SS)",model.getMessageTime() ) );
            }
        };

        listofMessage.setAdapter( adapter );

    }

}

Gradle构建模块:App

Gradle Build Module:App

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.example.aids.a09application"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        aaptOptions.cruncherEnabled = false
        aaptOptions.useNewCruncher = false

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
android {
    useLibrary 'org.apache.http.legacy'
}
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.google.firebase:firebase-core:11.2.0'
    compile 'com.google.firebase:firebase-messaging:11.2.0'
    compile 'com.android.support:appcompat-v7:26.0.1'
    compile 'com.google.android.gms:play-services-maps:11.2.0'
    compile 'com.google.firebase:firebase-auth:11.2.0' // ADDED
    compile 'com.google.android.gms:play-services-auth:11.2.0' // ADDED
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:26.0.1'
    compile 'com.android.support:support-v4:26.0.1'
    compile 'com.android.support:recyclerview-v7:26.0.1'
    compile 'com.firebaseui:firebase-ui-auth:2.3.0'
    compile 'com.firebaseui:firebase-ui:2.3.0'
}
apply plugin: 'com.google.gms.google-services'


推荐答案

我在阅读/写入firebase数据库时遇到了类似的问题,这个小改动对我有用。尝试删除不必要的firebase依赖项,并确保对所有使用的firebase依赖项使用相同的版本。在我的情况下,我改变了我的firebase依赖关系:

I had a similar problem while reading/writing to firebase database this small change worked for me. Try removing unnecessary firebase dependencies and make sure you use the same version for all the firebase dependencies for those that you use. In my case I changed my firebase dependencies from:

implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.0'

这些:

implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-core:11.8.0'

我确定你可能花了很多时间来解决这个问题。不妨结果值得一试:)

I'm sure you might have spent a lot of time trying to fix this. Might as well turn out worth a shot :)

这篇关于NoSuchMethodError:类Lcom / google / firebase / FirebaseApp中没有虚方法zzEq()Z;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆