android-无法解析符号“ FirebaseRecyclerOptions”

android-无法解析符号“ FirebaseRecyclerOptions”,第1张

概述我正在通过Firebase制作聊天Messenger,但我的Android Studio 2.3.2无法解析FirebaseRecyclerOptions

我正在通过Firebase制作聊天Messenger,但我的Android Studio 2.3.2无法解析FirebaseRecyclerOptions<甚至我的应用程序都已成功连接到Firebase,并且已正确配置到Firebase Realtime数据库,并且FirebaseRecyclerAdaper也已很好地导入.似乎build.gradle依赖项已同步且正常.我需要别人的帮助.以下是我在MainActivitIEs中的依赖和代码.在build.gradle中添加并尝试了其他几个依赖项

private FirebaseRecyclerAdapter<ChatMessage,MessageVIEwHolder> mFirebaseAdapter; // Ph4 Reading chatprivate static final String MESSAGES_CHILD = "messages"; // Ph3 Chat DBprivate DatabaseReference mFirebaseDatabaseReference; // Ph3 Chat DBprivate EditText mMessageEditText; // Ph3 DBprivate FirebaseAuth mFirebaseAuth;private FirebaseUser mFirebaseUser;private String mUsername; // Ph3 Chat DBprivate String mPhotoUrl; // Ph3 DBprivate Googleapiclient mGoogleapiclient; // Ph2 Log-out@OverrIDe // Ph2 Log-outpublic voID onConnectionFailed(@NonNull ConnectionResult connectionResult) {}public static class MessageVIEwHolder extends RecyclerVIEw.VIEwHolder { // 내부클래스    TextVIEw nameTextVIEw;    ImageVIEw messageImageVIEw;    TextVIEw messageTextVIEw;    circleimageVIEw photoImageVIEw;    public MessageVIEwHolder(VIEw itemVIEw) {        super(itemVIEw);        nameTextVIEw = (TextVIEw) itemVIEw.findVIEwByID(R.ID.nameTextVIEw);        messageImageVIEw = (ImageVIEw) itemVIEw.findVIEwByID(R.ID.messageImageVIEw);        messageTextVIEw = (TextVIEw) itemVIEw.findVIEwByID(R.ID.messageTextVIEw);        photoImageVIEw = (circleimageVIEw) itemVIEw.findVIEwByID(R.ID.photoImageVIEw);    }}private RecyclerVIEw mMessageRecyclerVIEw;@OverrIDeprotected voID onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentVIEw(R.layout.activity_main);    mFirebaseDatabaseReference = FirebaseDatabase.getInstance().getReference(); // Ph3 Chat DB    mMessageEditText = (EditText) findVIEwByID(R.ID.message_edit); // Ph3 DB    mMessageRecyclerVIEw = (RecyclerVIEw) findVIEwByID(R.ID.message_recycler_vIEw);    findVIEwByID(R.ID.send_button).setonClickListener(new VIEw.OnClickListener() { // Ph3 Chat DB        @OverrIDe        public voID onClick(VIEw v) {            ChatMessage chatMessage = new ChatMessage(mMessageEditText.getText().toString(),mUsername,mPhotoUrl,null);            mFirebaseDatabaseReference.child(MESSAGES_CHILD)                    .push()                    .setValue(chatMessage);            mMessageEditText.setText("");        }    });    mGoogleapiclient = new Googleapiclient.Builder(this) // Ph2 Log-out            .enableautoManage(this,this)            .addAPI(Auth.Google_SIGN_IN_API)            .build();    mFirebaseAuth = FirebaseAuth.getInstance();    mFirebaseUser = mFirebaseAuth.getCurrentUser();    if (mFirebaseUser == null) {        startActivity(new Intent(this,SignInActivity.class));        finish();        return;    } else {        mUsername = mFirebaseUser.getdisplayname();        if (mFirebaseUser.getPhotoUrl() != null ) {            mPhotoUrl = mFirebaseUser.getPhotoUrl().toString();        }    }    query query = mFirebaseDatabaseReference.child(MESSAGES_CHILD); // Ph4 Reading chat    FirebaseRecyclerOptions<ChatMessage> options = new FirebaseRecyclerOptions.Builder<ChatMessage>() //ph4            .setquery(query,ChatMessage.class)            .build();    mFirebaseAdapter = new FirebaseRecyclerAdapter<ChatMessage,MessageVIEwHolder>(options) { // Ph4 Reading chat        @OverrIDe        protected voID onBindVIEwHolder(MessageVIEwHolder holder,int position,ChatMessage model) {            holder.messageTextVIEw.setText(model.getText());            holder.nameTextVIEw.setText(model.getname());            if (model.getPhotoUrl() == null) {                holder.photoImageVIEw.setimageDrawable(ContextCompat.getDrawable(MainActivity.this,R.drawable.ic_account_circle_black_24dp));            } else {                GlIDe.with(MainActivity.this)                        .load(model.getPhotoUrl())                        .into(holder.photoImageVIEw);            }        }        @OverrIDe        public MessageVIEwHolder onCreateVIEwHolder(VIEwGroup parent,int vIEwType) {            VIEw vIEw = LayoutInflater.from(parent.getContext())                    .inflate(R.layout.item_message,parent,false);            return new MessageVIEwHolder(vIEw);        }        @OverrIDe        protected voID populateVIEwHolder(MessageVIEwHolder vIEwHolder,ChatMessage model,int position) {        }    };    mMessageRecyclerVIEw.setLayoutManager(new linearlayoutmanager(this)); // Ph4    mMessageRecyclerVIEw.setAdapter(mFirebaseAdapter); // Ph4}@OverrIDeprotected voID onStart() { // Ph4 Reading chat    super.onStart();    mFirebaseAdapter.startListening();}@OverrIDeprotected voID onStop() { // Ph4 Reading chat    super.onStop();    mFirebaseAdapter.stopListening();}@OverrIDe // Ph2 Log-outpublic boolean onCreateOptionsMenu(Menu menu) {    getMenuInflater().inflate(R.menu.main,menu);    return true;}@OverrIDe // Ph2 Log-outpublic boolean onoptionsItemSelected(MenuItem item) {    switch (item.getItemID()) {        case R.ID.sign_out_menu:            mFirebaseAuth.signOut();            Auth.GoogleSignInAPI.signOut(mGoogleapiclient);            mUsername = "";            startActivity(new Intent(this,SignInActivity.class));            finish();            return true;        default:            return super.onoptionsItemSelected(item);    } }}

>下面是build.gradle

    compile 'com.androID.support:appcompat-v7:25.3.1'    compile 'com.androID.support.constraint:constraint-layout:1.0.2'    compile 'com.androID.support:recyclervIEw-v7:25.3.1'    compile 'com.androID.support.test:runner:0.5'    compile 'de.hdodenhof:circleimagevIEw:3.0.0'    compile 'com.Google.firebase:firebase-database:11.0.0'    compile 'com.Google.firebase:firebase-auth:11.0.0'    testCompile 'junit:junit:4.12'    compile 'com.Google.androID.gms:play-services-auth:11.0.0'    compile 'com.firebaseui:firebase-ui-database:2.0.0'    compile 'com.github.bumptech.glIDe:glIDe:4.6.0'    annotationProcessor 'com.github.bumptech.glIDe:compiler:4.6.0'}apply plugin: 'com.Google.gms.Google-services'
最佳答案您需要更新firebaseui依赖性,在build.gradle中使用以下内容:

implementation 'com.firebaseui:firebase-ui-database:4.3.2' 

firebaseui 3.0中添加了FirebaseRecyclerOptions,而您使用的是firebaseui 2.0,这就是您收到该错误的原因.

更多信息在这里:

https://github.com/firebase/FirebaseUI-Android/blob/master/database/README.md

检查以下内容:

Adapter initialization – in prevIoUs versions the adapter classes (FirebaseRecyclerAdapter,Firebaselistadapter,etc) had multiple constructor overloads. In 3.x,each adapter has a single constructor that takes an Options object like FirebaseRecyclerOptions. These options objects can be constructed via their respective builders. For more information,see database/README.md.

https://github.com/firebase/FirebaseUI-Android/blob/master/docs/upgrade-to-3.0.md#realtime-database 总结

以上是内存溢出为你收集整理的android-无法解析符号“ FirebaseRecyclerOptions” 全部内容,希望文章能够帮你解决android-无法解析符号“ FirebaseRecyclerOptions” 所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1145003.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-31
下一篇 2022-05-31

发表评论

登录后才能评论

评论列表(0条)

保存